thumbnail generation does not work after upgrade

Found a bug? Tell us!!
Post Reply
zoran
Regular
Posts: 71
Joined: Sun Jan 16, 2005 9:13 pm
Location: Amsterdam
Contact:

thumbnail generation does not work after upgrade

Post by zoran »

Hi all,

My upgrade to 1.2 appeared to go swell. Until I tried to upload an image: thumbnails are not generated anymore.

In my image conversion settings, the 'thumbnail dimensions' variable is set to 320px. An upload of an image used to result in a thumbnail. Now only the original image appears in the media library.

Any pointers?

Best regards,
Zoran
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: thumbnail generation does not work after upgrade

Post by garvinhicking »

Hi!

So in your upload directory, no file with ".serendipityThumb" gets created? Or does it, and it's simply the same size?

How large was your original file? Larger or smaller than 320px?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
zoran
Regular
Posts: 71
Joined: Sun Jan 16, 2005 9:13 pm
Location: Amsterdam
Contact:

Re: thumbnail generation does not work after upgrade

Post by zoran »

Hi Garv,

I somehow expected an answer from you :D
garvinhicking wrote:So in your upload directory, no file with ".serendipityThumb" gets created? Or does it, and it's simply the same size?

How large was your original file? Larger or smaller than 320px?
E.g. http://www.kovacevic.nl/blog/uploads/09092007770.jpg

The image is 1600x1200px. No .serendipityThumb gets created.

Compare with:
http://www.kovacevic.nl/blog/uploads/18082007755.jpg
and
http://www.kovacevic.nl/blog/uploads/18 ... yThumb.jpg
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: thumbnail generation does not work after upgrade

Post by garvinhicking »

Hi!

Hm, that's strange, the image generation thing has not really changed in the last s9y version. Assuming you upgraded frmo s9y 1.1.

Can you try to upload a small picture (like 400x400 pixel)? It might be memory related, maybe your JPG hits some kind of barrier.

Are you using imagemagick or gdlib thumbnail creation?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
zoran
Regular
Posts: 71
Joined: Sun Jan 16, 2005 9:13 pm
Location: Amsterdam
Contact:

Re: thumbnail generation does not work after upgrade

Post by zoran »

Hola,

Yes, I upgraded from 1.1.

Uploaded this:
http://www.kovacevic.nl/blog/uploads/Untitled.jpg

In the Media library it says:

Orig.: 244x208, Thumb: 244x208
13.81kb

ImageMagick is set to 'no', so I guess I'm using gdlib?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: thumbnail generation does not work after upgrade

Post by garvinhicking »

Hi!

Can you check the serendipity_images DB table and see which columns are set for that Untitled image? Especially the "thumb" part would be important.
ImageMagick is set to 'no', so I guess I'm using gdlib?
Yip, that's true. Did anything else change on the server when you upgraded? New PHP version maybe?

We might need to get into debugging some code, if the questions above lead no further.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
zoran
Regular
Posts: 71
Joined: Sun Jan 16, 2005 9:13 pm
Location: Amsterdam
Contact:

Post by zoran »

Hi Garv (thanks for your time!)

Here's a part of the serendipity_images table, showing the last 4 entries. The last two are the test entries from my previous posts. The first two are the most recent success ones (from before the upgrade):

INSERT INTO `serendipity_images` VALUES (123, '29082007763', 'jpg', 'image/jpeg', 647002, 1200, 1531, 1188664585, 'serendipityThumb', 0, '', NULL, '29082007763.jpg');
INSERT INTO `serendipity_images` VALUES (124, '04082007732', 'jpg', 'image/jpeg', 405031, 1600, 1200, 1188921628, 'serendipityThumb', 0, '', NULL, '04082007732.jpg');
INSERT INTO `serendipity_images` VALUES (132, '09092007770', 'jpg', 'image/jpeg', 782632, 1600, 1200, 1189449017, '', 0, '', NULL, '09092007770.jpg');
INSERT INTO `serendipity_images` VALUES (134, 'Untitled', 'jpg', 'image/jpeg', 14143, 244, 208, 1189502841, '', 0, '', NULL, 'Untitled.jpg');

I am not aware of a PHP upgrade. Here's my phpinfo():
http://www.kovacevic.nl/hacks/phpinfo.php
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi Zoran!

Okay, then let's get down dirty.

Please open your include/admin/images.inc.php. At around line 318 you should see this:

Code: Select all

// Accept file
if (is_uploaded_file($uploadtmp) && serendipity_checkMediaSize($uploadtmp) && move_uploaded_file($uploadtmp, $target)) {
    printf(FILE_UPLOADED . '<br />', $uploadfile, $target);
    @umask(0000);
    @chmod($target, 0664);

    $thumbs = array(array(
        'thumbSize' => $serendipity['thumbSize'],
        'thumb'     => $serendipity['thumbSuffix']
    ));
    serendipity_plugin_api::hook_event('backend_media_makethumb', $thumbs);

    foreach($thumbs as $thumb) {
        // Create thumbnail
        if ( $created_thumbnail = serendipity_makeThumbnail($tfile, $serendipity['POST']['target_directory'][$idx], $thumb['thumbSize'], $thumb['thumb']) ) {
            echo THUMB_CREATED_DONE . '<br />';
        }
    }

    // Insert into database
    $image_id = serendipity_insertImageInDatabase($tfile, $serendipity['POST']['target_directory'][$idx], $authorid, null, $realname);
    serendipity_plugin_api::hook_event('backend_image_add', $target, $created_thumbnail);
    $new_media[] = array(
        'image_id'          => $image_id,
        'target'            => $target,
        'created_thumbnail' => $created_thumbnail
    );
} else {
    echo ERROR_UNKNOWN_NOUPLOAD . '<br />';
}
This is the code that gets executed when you upload an image.

Please modify that piece of code with this:

Code: Select all

// Accept file
if (is_uploaded_file($uploadtmp) && serendipity_checkMediaSize($uploadtmp) && move_uploaded_file($uploadtmp, $target)) {
    printf(FILE_UPLOADED . '<br />', $uploadfile, $target);
    @umask(0000);
    @chmod($target, 0664);

    $thumbs = array(array(
        'thumbSize' => $serendipity['thumbSize'],
        'thumb'     => $serendipity['thumbSuffix']
    ));
    
    echo 'Garvin debug #1: <pre>' . print_r($thumbs, true) . '</pre><br />';
    serendipity_plugin_api::hook_event('backend_media_makethumb', $thumbs);
    echo 'Garvin debug #2: <pre>' . print_r($thumbs, true) . '</pre><br />';

    foreach($thumbs as $thumb) {
        // Create thumbnail
        if ( $created_thumbnail = serendipity_makeThumbnail($tfile, $serendipity['POST']['target_directory'][$idx], $thumb['thumbSize'], $thumb['thumb']) ) {
            echo THUMB_CREATED_DONE . '<br />';
        } else {
            echo 'Garvin debug #3: Thumbnail failed. Further debugging of serendipity_makeThumbnail needed: <pre>' . print_r($created_thumbnail, true) . '</pre><br />';
        }
    }

    // Insert into database
    $image_id = serendipity_insertImageInDatabase($tfile, $serendipity['POST']['target_directory'][$idx], $authorid, null, $realname);
    serendipity_plugin_api::hook_event('backend_image_add', $target, $created_thumbnail);
    $new_media[] = array(
        'image_id'          => $image_id,
        'target'            => $target,
        'created_thumbnail' => $created_thumbnail
    );
} else {
    echo ERROR_UNKNOWN_NOUPLOAD . '<br />';
}
Then upload a file and tell me the output you get?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
zoran
Regular
Posts: 71
Joined: Sun Jan 16, 2005 9:13 pm
Location: Amsterdam
Contact:

Post by zoran »

Code: Select all

Adding image...


File 09092007768.jpg successfully uploaded as /var/sites/nl.kovacevic.www/www/blog/uploads/09092007768.jpg
Garvin debug #1:

Array
(
    [0] => Array
        (
            [thumbSize] => 320
            [thumb] => serendipityThumb
        )

)


Garvin debug #2:

Array
(
    [0] => Array
        (
            [thumbSize] => 320
            [thumb] => serendipityThumb
        )

)


Garvin debug #3: Thumbnail failed. Further debugging of serendipity_makeThumbnail needed:
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi Zoran!

Okay, thanks. serendipity_makeThumbnail() fails on the setup. Please open your include/functions_images.inc.php and replace that function with:

Code: Select all

function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumbname = false, $is_temporary = false, $force_resize = false) {
    global $serendipity;

    if ($size === false) {
        $size = $serendipity['thumbSize'];
    }

    if ($thumbname === false) {
        $thumbname = $serendipity['thumbSuffix'];
    }

    $t       = serendipity_parseFileName($file);
    $f       = $t[0];
    $suf     = $t[1];


    $infile  = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $file;
    echo 'From: ' . $infile . '<br />';
    if ($is_temporary) {
        $temppath = dirname($thumbname);
        if (!is_dir($temppath)) {
            @mkdir($temppath);
        }
        $outfile = $thumbname;
    } else {
        $outfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $f . '.' . $thumbname . '.' . $suf;
    }
    $serendipity['last_outfile'] = $outfile;
    echo 'To: ' . $outfile . '<br />';

    $fdim    = serendipity_getimagesize($infile, '', $suf);
    echo 'FDIM (' . $suf . '): <pre>' . print_r($fdim, true) . '</pre><br />';
    if (isset($fdim['noimage'])) {
        $r = array(0, 0);
    } else {
        if ($serendipity['magick'] !== true) {
            echo 'Using GD...<br />';
            if (is_array($size)) {
                $r = serendipity_resize_image_gd($infile, $outfile, $size['width'], $size['height']);
            } else {
                $r = serendipity_resize_image_gd($infile, $outfile, $size);
            }
            echo 'Output: <pre>' . print_r($r, true) . '</pre><br />';
        } else {
            echo 'Whoops! You have configured imagemagick! That aint right.<br />';
            if (is_array($size)) {
                $r = $size;
            } else {
                $r = array('width' => $size, 'height' => $size);
            }
            $newSize = $r['width'] . 'x' . $r['height'];
            if ($fdim['mime'] == 'application/pdf') {
                $cmd     = escapeshellcmd($serendipity['convert']) . ' -antialias -flatten -scale '. serendipity_escapeshellarg($newSize) .' '. serendipity_escapeshellarg($infile) .' '. serendipity_escapeshellarg($outfile . '.png');
            } else {
                if (!$force_resize && serendipity_ini_bool(ini_get('safe_mode')) === false) {
                    $newSize .= '>'; // Tell imagemagick to not enlarge small images, only works if safe_mode is off (safe_mode turns > in to \>)
                }
                $cmd     = escapeshellcmd($serendipity['convert']) . ' -antialias -resize '. serendipity_escapeshellarg($newSize) .' '. serendipity_escapeshellarg($infile) .' '. serendipity_escapeshellarg($outfile);
            }
            exec($cmd, $output, $result);
            if ($result != 0) {
                echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</div>';
                $r = false; // return failure
            } else {
               touch($outfile);
            }
            unset($output, $result);
        }
    }

    return $r;
}
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
zoran
Regular
Posts: 71
Joined: Sun Jan 16, 2005 9:13 pm
Location: Amsterdam
Contact:

Post by zoran »

Hi

Code: Select all

Adding image...


File 02092007766.jpg successfully uploaded as /var/sites/nl.kovacevic.www/www/blog/uploads/02092007766.jpg
From: /var/sites/nl.kovacevic.www/www/blog/uploads/02092007766.jpg
To: /var/sites/nl.kovacevic.www/www/blog/uploads/02092007766.serendipityThumb.jpg
FDIM (jpg):

Array
(
    [0] => 1600
    [1] => 1200
    [2] => 2
    [3] => width="1600" height="1200"
    [bits] => 8
    [channels] => 3
    [mime] => image/jpeg
)


Using GD...
Output:

There is no content after 'Output:'

:?:
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

LOL. If I only had looked earlier at your phpinfo().

There is no libgd library used anymore! Seems that changed for you! Maybe on July the 30th, that is the time of your new PHP version?

The s9y function fails, because the function 'imagecopyresampled' does not exist!

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
zoran
Regular
Posts: 71
Joined: Sun Jan 16, 2005 9:13 pm
Location: Amsterdam
Contact:

Post by zoran »

garvinhicking wrote:LOL. If I only had looked earlier at your phpinfo().

There is no libgd library used anymore! Seems that changed for you! Maybe on July the 30th, that is the time of your new PHP version?
That's very strange (it usually is ;)) because I have certainly had successful uploads last month. I'll have a look where libgd went :S

Thanks for your time and effort!
zoran
Regular
Posts: 71
Joined: Sun Jan 16, 2005 9:13 pm
Location: Amsterdam
Contact:

Post by zoran »

Okay, so my sysadmin removed several dotdeb dependencies ... reset it now, everything is back to normal.

So no bug in s9y (what was I thinking? ;))
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Good to see that mystery solved :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply