The following code:
$phpThumb = new phpThumb();
$phpThumb->setParameter( "config_imagemagick_path", CMD_CONVERT_PATH );
$phpThumb->setParameter( "config_output_format", $output_format );
$phpThumb->setParameter( "w", 600 );
$phpThumb->setParameter( "h", 800 );
$phpThumb->setParameter( "fltr", null );
$phpThumb->setSourceFilename( $source_file_path );
if ( $phpThumb->GenerateThumbnail() )
$phpThumb->RenderToFile( PHOTO_UPLOAD_DIR."/".$subdir."/".$lid.".".$output_format );
Doesn't work on big pictures.
I see the mistake in function
phpThumb::ImageMagickThumbnailToGD(), where fltr is in UnAllowedParameters, but $fltr is an array it's allways set, so useRawIMoutput becomes false and $outputFormat becomes 'png'. Why?
Here, phpThumbs debug log:
Array
(
[0] => phpThumb() v1.7.7-200612252156 in file "phpthumb.class.php" on line 216
[1] => setSourceFilename(uploads/src/38) set $this->sourceFilename to "uploads/src/38" in file "phpthumb.class.php" on line 234
[2] => file_exists(/usr/bin/convert) = 1 in file "phpthumb.class.php" on line 1036
[3] => is_executable(/usr/bin/convert) = 1 in file "phpthumb.class.php" on line 1037
[4] => using ImageMagick path from $this->config_imagemagick_path (/usr/bin/convert) in file "phpthumb.class.php" on line 1039
[5] => ImageMagick version checked with ""/usr/bin/convert" --version" in file "phpthumb.class.php" on line 1083
[6] => ImageMagick convert --version says "Version: ImageMagick 6.3.3 05/07/07 Q16 http:" in file "phpthumb.class.php" on line 1091
[7] => Addding ImageMagick formats to $AvailableImageOutputFormats (text;ico;bmp;wbmp;gif;png;jpeg) in file "phpthumb.class.php" on line 819
[8] => $AvailableImageOutputFormats = array(text;ico;bmp;wbmp;gif;png;jpeg) in file "phpthumb.class.php" on line 825
[9] => $this->thumbnailFormat set to $this->config_output_format "jpeg" in file "phpthumb.class.php" on line 835
[10] => $this->thumbnailQuality set to "75" in file "phpthumb.class.php" on line 852
[11] => $this->sourceFilename set to "/www/profiles5.inbox.lv/uploads/src/38" in file "phpthumb.class.php" on line 754
[12] => setCacheDirectory() starting with config_cache_directory = "" in file "phpthumb.class.php" on line 859
[13] => $this->config_cache_directory () is not a directory in file "phpthumb.class.php" on line 895
[14] => SetCacheFilename() failed because $this->config_cache_directory is empty in file "phpthumb.class.php" on line 2809
[15] => starting ExtractEXIFgetImageSize() in file "phpthumb.class.php" on line 2666
[16] => $this->useRawIMoutput=false because "fltr" is set in file "phpthumb.class.php" on line 1151
[17] => phpThumb_tempnam() returning "/tmp/pThumbaLgf9X" in file "phpthumb.class.php" on line 3606
[18] => ImageMagickSwitchAvailable(thumbnail) = 1 in file "phpthumb.class.php" on line 1123
[19] => ImageMagickSwitchAvailable(modulate) = 1 in file "phpthumb.class.php" on line 1123
[20] => GetImageSize(/www/profiles5.inbox.lv/uploads/src/38) SUCCEEDED: a:7:{i:0;i:2592;i:1;i:1944;i:2;i:2;i:3;s:26:"width="2592" height="1944"";s:4:"bits";i:8;s:8:"channels";i:3;s:4:"mime";s:10:"image/jpeg";} in file "phpthumb.class.php" on line 1239
[21] => GetImageSize(/www/profiles5.inbox.lv/uploads/src/38) returned [w=2592;h=1944;f=2] in file "phpthumb.class.php" on line 1244
[22] => source dimensions set to 2592x1944 in file "phpthumb.class.php" on line 1247
[23] => SetOrientationDependantWidthHeight() starting with "2592"x"1944" in file "phpthumb.class.php" on line 2645
[24] => SetOrientationDependantWidthHeight() setting w="600", h="400" in file "phpthumb.class.php" on line 2661
[25] => Processed $this->fltr[0] () with ImageMagick in file "phpthumb.class.php" on line 1680
[26] => Remaining $this->fltr after ImageMagick: (<pre> <b>array</b> 0 <font color='#888a85'>=></font> <font color='#3465a4'>null</font> </pre>) in file "phpthumb.class.php" on line 1685
[27] => ImageMagick called as ("/usr/bin/convert" -density 150 -thumbnail 600x400 "/www/profiles5.inbox.lv/uploads/src/38[0]" png:"/tmp/pThumbaLgf9X" 2>&1) in file "phpthumb.class.php" on line 1701
[28] => ImageMagick failed with message (convert: no decode delegate for this image format `/www/profiles5.inbox.lv/uploads/src/38'.
convert: missing an image filename `png:/tmp/pThumbaLgf9X'.) in file "phpthumb.class.php" on line 1706
[29] => ImageMagickThumbnailToGD() failed in file "phpthumb.class.php" on line 2696
[30] => SetOrientationDependantWidthHeight() starting with "2592"x"1944" in file "phpthumb.class.php" on line 2645
[31] => SetOrientationDependantWidthHeight() setting w="600", h="400" in file "phpthumb.class.php" on line 2661
[32] => exif_thumbnail() does not exist, cannot extract EXIF thumbnail in file "phpthumb.class.php" on line 2743
[33] => starting SourceImageToGD() in file "phpthumb.class.php" on line 3006
[34] => $this->useRawIMoutput=false because "fltr" is set in file "phpthumb.class.php" on line 1151
[35] => phpThumb_tempnam() returning "/tmp/pThumbrkMcC7" in file "phpthumb.class.php" on line 3606
[36] => ImageMagickSwitchAvailable(thumbnail) = 1 in file "phpthumb.class.php" on line 1123
[37] => ImageMagickSwitchAvailable(modulate) = 1 in file "phpthumb.class.php" on line 1123
[38] => GetImageSize(/www/profiles5.inbox.lv/uploads/src/38) SUCCEEDED: a:7:{i:0;i:2592;i:1;i:1944;i:2;i:2;i:3;s:26:"width="2592" height="1944"";s:4:"bits";i:8;s:8:"channels";i:3;s:4:"mime";s:10:"image/jpeg";} in file "phpthumb.class.php" on line 1239
[39] => GetImageSize(/www/profiles5.inbox.lv/uploads/src/38) returned [w=2592;h=1944;f=2] in file "phpthumb.class.php" on line 1244
[40] => source dimensions set to 2592x1944 in file "phpthumb.class.php" on line 1247
[41] => SetOrientationDependantWidthHeight() starting with "2592"x"1944" in file "phpthumb.class.php" on line 2645
[42] => SetOrientationDependantWidthHeight() setting w="600", h="400" in file "phpthumb.class.php" on line 2661
[43] => Processed $this->fltr[0] () with ImageMagick in file "phpthumb.class.php" on line 1680
[44] => Remaining $this->fltr after ImageMagick: (<pre> <b>array</b> 0 <font color='#888a85'>=></font> <font color='#3465a4'>null</font> </pre>) in file "phpthumb.class.php" on line 1685
[45] => ImageMagick called as ("/usr/bin/convert" -density 150 -thumbnail 600x400 "/www/profiles5.inbox.lv/uploads/src/38[0]" png:"/tmp/pThumbrkMcC7" 2>&1) in file "phpthumb.class.php" on line 1701
[46] => ImageMagick failed with message (convert: no decode delegate for this image format `/www/profiles5.inbox.lv/uploads/src/38'.
convert: missing an image filename `png:/tmp/pThumbrkMcC7'.) in file "phpthumb.class.php" on line 1706
[47] => Not using EXIF thumbnail data because $this->exif_thumbnail_data is empty in file "phpthumb.class.php" on line 3047
[48] => $this->gdimg_source is still empty in file "phpthumb.class.php" on line 3099
[49] => ImageMagickThumbnailToGD() failed in file "phpthumb.class.php" on line 3101
[50] => phpThumb() v1.7.7-200612252156
All attempts to create GD image source failed.
ImageMagick failed with message (convert: no decode delegate for this image format `/www/profiles5.inbox.lv/uploads/src/38'.
convert: missing an image filename `png:/tmp/pThumbrkMcC7'.)
Source image is too large (2592x1944 = 5.0Mpx, max=1.7Mpx) for GD creation (either install ImageMagick or increase PHP memory_limit to at least 28M). in file "phpthumb.class.php" on line 3405
[51] => phpThumb() v1.7.7-200612252156
Image is too large for PHP-GD memory_limit, please install ImageMagick or increase php.ini memory_limit setting in file "phpthumb.class.php" on line 3405
[52] => SourceImageToGD() failed in file "phpthumb.class.php" on line 312
)
Logged In: YES
user_id=429434
Originator: NO
See debug line #28:
ImageMagick failed with message (convert: no decode delegate
for this image format `/www/profiles5.inbox.lv/uploads/src/38'.
convert: missing an image filename `png:/tmp/pThumbaLgf9X'.)
Basically, ImageMagick is failing because it doesn't know how to handle the uploaded image. You can try recompiling ImageMagick? The only other solution is to increase the memory_limit for PHP to be able to handle such large images (you'll need about 32MB).
Logged In: YES
user_id=1129203
Originator: YES
Yes, I know, the problem was because of lack of imagemagic libraries in my chroot environment.
But the problem with was exactly as I described above and seems it's still persists in the latest release.
Take a look at these lines:
[34] => $this->useRawIMoutput=false because "fltr" is set in file "phpthumb.class.php" on line 1151
[45] => ImageMagick called as ("/usr/bin/convert" ... png:"/tmp/pThumbrkMcC7" 2>&1) in file "phpthumb.class.php" on line 1701
I wonder why it's choosing to save my file as png while I implicitly set the output format. As I understand, the error code is in function ImageMagickThumbnailToGD:
$UnAllowedParameters = array('xto', 'ra', 'ar', 'bg', 'bc', 'fltr'); // fltr is always set as it is an array
foreach ($UnAllowedParameters as $parameter) {
if (isset($this->$parameter)) {
$this->useRawIMoutput = false;
break;
}
}
...
if ($this->useRawIMoutput) { // useRawIMoutput is always false here
switch ($this->thumbnailFormat) {
...
}
} else {
$outputFormat = 'png';
$ImageCreateFunction = 'ImageCreateFromPNG';
$this->useRawIMoutput = false;
}
Correct me if I'm wrong. Thank you.
Logged In: YES
user_id=429434
Originator: NO
The problem is your line:
$phpThumb->setParameter( "fltr", null );
That creates a new filter with a value of NULL, so $this->fltr == array(0=>null) instead of being an empty array.
I have added some code to check for (and remove) invalid filter values. If you want a copy of the latest test version, please send an email to info@silisoftware.com
Logged In: YES
user_id=1129203
Originator: YES
Yep you're right, this was just my try to reset fltr that failed. Even without this line it doesn't work. Consider the following example:
<?php
$arr = array();
if ( isset( $arr ) )
print "Empty array is set!<br>";
array_push( $arr, null );
if ( isset( $arr ) )
print "Null array is also set!<br>";
?>
Which gives to me:
Empty array is set!
Null array is also set!
That's why fltr is _always_ set and ImageMagickThumbnailToGD() gives me PNG.
Thank you for this check you've added, please also add check if parameter in $UnAllowedParameters is an array and is empty.
Thank you.
Logged In: YES
user_id=429434
Originator: NO
Feel free to test the latest beta version and reopen this ticket if the problem is not fixed.
http://phpthumb.sourceforge.net/#download