Resize Produces Half Empty PNG's in Firefox, Safari Blank

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
merrick

Resize Produces Half Empty PNG's in Firefox, Safari Blank

Post by merrick »

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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Resize Produces Half Empty PNG's in Firefox, Safari Blank

Post by magick »

Add +repage after the -resize option. Let us know if that fixes the problem you reported.
merrick

Re: Resize Produces Half Empty PNG's in Firefox, Safari Blank

Post by merrick »

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 &" );
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Resize Produces Half Empty PNG's in Firefox, Safari Blank

Post by magick »

The repage option must appear *before* the output image filename.
merrick

Re: Resize Produces Half Empty PNG's in Firefox, Safari Blank

Post by merrick »

Oops, I tried this and the image does not display, same result.

exec( "mogrify -resize '240x240>' +repage $image_thumb_240 &" );
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Resize Produces Half Empty PNG's in Firefox, Safari Blank

Post by magick »

We cannot reproduce the problem you are having. You could try the latest ImageMagick release, 6.3.6-3.
merrick

Re: Resize Produces Half Empty PNG's in Firefox, Safari Blank

Post by merrick »

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.
merrick

Re: Resize Produces Half Empty PNG's in Firefox, Safari Blank

Post by merrick »

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.
kunderez
Posts: 1
Joined: 2011-06-14T01:57:39-07:00
Authentication code: 8675308

Re: Resize Produces Half Empty PNG's in Firefox, Safari Blan

Post by kunderez »

Download this image Image
... and run following command

Code: Select all

convert Papua_New_Guinea_map.png +repage PNG:magic_happens.png
.. 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

Code: Select all

convert Papua_New_Guinea_map.png -type TrueColor +repage PNG:magic_happens_not.png
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
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Resize Produces Half Empty PNG's in Firefox, Safari Blan

Post by glennrp »

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.
Post Reply