Jump to content

[SOLVED] Why doesn't script echo "thumbnail generated" while running through FOR loop..


cgm225

Recommended Posts

The following FOR loop does not echo anything until it is complete.  Is there a way to make it echo while it is executing, i.e. each time it passes through, echo the "thumbnail generated" statements?

 

if ($action == "generate_all") {

        $image = 0;
        for($i = 1; $i >= 0; $i++) {

        buffer($image);
      
        if (file_exists("$photos_server_path/photos/$album/$buffer$image.jpg")) {
            echo "$buffer$image: ";
            if (file_exists("$photos_server_path/photos/$album/thumbnails/large_thumbnail-$image.jpg")) {} else {
                system("convert $photos_server_path/photos/$album/$buffer$image.jpg -resize 500x -quality 100 $photos_server_path/photos/$album/thumbnails/large_thumbnail-$image.jpg");
                echo "Large thumbnail generated! | "; 
                }
            if (file_exists("$photos_server_path/photos/$album/thumbnails/small_thumbnail-$image.jpg")) {} else {
                list($image_width, $image_height) = getimagesize("$photos_server_path/photos/$album/$buffer$image.jpg");
                if ($image_height > $image_width) {
                    $small_thumbnail_height = ceil(250 * ($image_width/$image_height));
                    } else {
                    $small_thumbnail_height = ceil(250 * ($image_height/$image_width));}
                system("convert $photos_server_path/photos/$album/$buffer$image.jpg -resize 250x -gravity center -quality 100 -crop 250x$small_thumbnail_height+0+0 $photos_server_path/photos/$album/thumbnails/small_thumbnail-$image.jpg");
                echo "Small thumbnail generated!<br>";
                }

            $next_image_addage = $image;
            $image = $next_image_addage + 1;
            } else {
            $i = -5;
            }
        }
    }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.