Resize Produces Half Empty PNG's in Firefox, Safari Blank
Resize Produces Half Empty PNG's in Firefox, Safari Blank
Debian 2.4.27-3-386
PHP 4.4.4-8+etch3
Imagemagick 6.2.4.5.dfsg1-0.14
Apache 2.2.3-4
Source File:
http://www.sandiegoish.com/imagemagick/140.png
Resized Problem File:
http://www.sandiegoish.com/imagemagick/140_240.png
Resized Smaller OK File:
http://www.sandiegoish.com/imagemagick/140_75.png
When I use the following commands on a PNG, the resize to 240x240 produces a half empty image or non displayable image on Firefox, Safari, Preview and Photoshop on a Mac. It will not even handle the resized image. For some reason, resize with dimensions of 75x75 produces a displayable image. I have exported the same image from Photoshop using numerous combinations of PNG settings with and without transparency and get the same results. All commands I use produce GIF's and JPEG's that display properly.
copy($image_file, $image_thumb_240);
copy($image_file, $image_thumb_75);
exec( "mogrify -resize '240x240>' $image_thumb_240 &" );
exec( "mogrify -resize '75x75>' $image_thumb_75 &" );
chmod($image_thumb_240, 0440);
chmod($image_thumb_75, 0440);
I also tried and encountered the same problem with the convert command below.
exec( "convert $image_file -resize '240x240' $image_thumb_240&" );
Any ideas on how to resolve this would be greatly appreciated. Hopefully it's not a bug, in which case sorry for the wrong category posting. I did search through the archives and Google before posting here.
PHP 4.4.4-8+etch3
Imagemagick 6.2.4.5.dfsg1-0.14
Apache 2.2.3-4
Source File:
http://www.sandiegoish.com/imagemagick/140.png
Resized Problem File:
http://www.sandiegoish.com/imagemagick/140_240.png
Resized Smaller OK File:
http://www.sandiegoish.com/imagemagick/140_75.png
When I use the following commands on a PNG, the resize to 240x240 produces a half empty image or non displayable image on Firefox, Safari, Preview and Photoshop on a Mac. It will not even handle the resized image. For some reason, resize with dimensions of 75x75 produces a displayable image. I have exported the same image from Photoshop using numerous combinations of PNG settings with and without transparency and get the same results. All commands I use produce GIF's and JPEG's that display properly.
copy($image_file, $image_thumb_240);
copy($image_file, $image_thumb_75);
exec( "mogrify -resize '240x240>' $image_thumb_240 &" );
exec( "mogrify -resize '75x75>' $image_thumb_75 &" );
chmod($image_thumb_240, 0440);
chmod($image_thumb_75, 0440);
I also tried and encountered the same problem with the convert command below.
exec( "convert $image_file -resize '240x240' $image_thumb_240&" );
Any ideas on how to resolve this would be greatly appreciated. Hopefully it's not a bug, in which case sorry for the wrong category posting. I did search through the archives and Google before posting here.
Re: Resize Produces Half Empty PNG's in Firefox, Safari Blank
Add +repage after the -resize option. Let us know if that fixes the problem you reported.
Re: Resize Produces Half Empty PNG's in Firefox, Safari Blank
Thank you, I tried the following and the resized image is still not displaying properly or at all.
exec( "mogrify -resize '240x240>' $image_thumb_240 +repage &" );
exec( "mogrify -resize '240x240>' $image_thumb_240 +repage &" );
Re: Resize Produces Half Empty PNG's in Firefox, Safari Blank
The repage option must appear *before* the output image filename.
Re: Resize Produces Half Empty PNG's in Firefox, Safari Blank
Oops, I tried this and the image does not display, same result.
exec( "mogrify -resize '240x240>' +repage $image_thumb_240 &" );
exec( "mogrify -resize '240x240>' +repage $image_thumb_240 &" );
Re: Resize Produces Half Empty PNG's in Firefox, Safari Blank
We cannot reproduce the problem you are having. You could try the latest ImageMagick release, 6.3.6-3.
Re: Resize Produces Half Empty PNG's in Firefox, Safari Blank
Thank you for trying, I will try updating.
I did try resizing the image on an older redhat server running an older version of ImageMagick and that worked fine.
I did try resizing the image on an older redhat server running an older version of ImageMagick and that worked fine.
Re: Resize Produces Half Empty PNG's in Firefox, Safari Blank
Apologies for the bug in my code that prompted this thread. As you stated, there is no problem like I described within ImageMagick.
After lots of wrangling with packages and code, I found the problem in my php code that displayed the image. It was getting the incorrect file size, that of the original file. The problem appeared when I uploaded small files 5kb or so, and when the smaller dimensioned, resized file, grew to a larger file size (10kb after resize).
My php code would only display 5kb of a 10kb file. When I right clicked and saved the file through the browser, I was storing a garbage file. When I attempted to view such garbage file, firefox showed as many bytes of the file as my php code said it was. When I tried safari it did not display an image, nor did photoshop or preview.
Just thought I should wrap it up, again sorry for the hassle.
After lots of wrangling with packages and code, I found the problem in my php code that displayed the image. It was getting the incorrect file size, that of the original file. The problem appeared when I uploaded small files 5kb or so, and when the smaller dimensioned, resized file, grew to a larger file size (10kb after resize).
My php code would only display 5kb of a 10kb file. When I right clicked and saved the file through the browser, I was storing a garbage file. When I attempted to view such garbage file, firefox showed as many bytes of the file as my php code said it was. When I tried safari it did not display an image, nor did photoshop or preview.
Just thought I should wrap it up, again sorry for the hassle.
Re: Resize Produces Half Empty PNG's in Firefox, Safari Blan
Download this image 
... and run following command
.. then you'll see what merrick was experiencing(?)...
My solution to this strange behaviour was to add "-type TrueColor" ... so running the following command gives me the desired results
ImageMagick Version: ImageMagick 6.2.8 10/20/10 Q16
Platform: Linux 2.6.18-238.9.1.el5 #1 SMP Tue Apr 12 18:10:13 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux

... and run following command
Code: Select all
convert Papua_New_Guinea_map.png +repage PNG:magic_happens.png
My solution to this strange behaviour was to add "-type TrueColor" ... so running the following command gives me the desired results
Code: Select all
convert Papua_New_Guinea_map.png -type TrueColor +repage PNG:magic_happens_not.png
Platform: Linux 2.6.18-238.9.1.el5 #1 SMP Tue Apr 12 18:10:13 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
Re: Resize Produces Half Empty PNG's in Firefox, Safari Blan
Please upgrade to a recent version of ImageMagick (6.7.0-x). The bug you
observed was fixed somewhere in the 6.6.x series.
A PNG of PNG... nice.
observed was fixed somewhere in the 6.6.x series.
A PNG of PNG... nice.