convert -crop ... fails on png files

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
janilrau

convert -crop ... fails on png files

Post by janilrau »

I'm experiencing serious trouble when cropping PNG images...

Here my example. The size of the image is 26,8 MB (3988 x 4288 pixel) and it is located here:
http://www.posterjack.com/kj_tmp/200803 ... 4_leri.png

and then try this (the error I got during crop operation of PNG files):
# flip image (works!)
convert 20080331091752540734_leri.png +flip 20080331091752540734_mx.png

# now crop a region
# Convert issues a warning and generates the 1 px transparent file named 20080331091752540734_bo.png, but it should crop the indicated region

convert 20080331091752540734_mx.png -crop 3988x572+0+0 20080331091752540734_bo.png



Afterwards try this (works fine, only difference: now processing JPG files):
# flip image (works!)
convert 20080331091752540734_leri.png +flip 20080331091752540734_mx.jpg

# now crop a region
# Convert cropes the region correctly

convert 20080331091752540734_mx.jpg -crop 3988x572+0+0 20080331091752540734_bo.jpg

I would prefer to process PNG due to the lossless compression/decompression. Is there a workaround for this bug?

Thanks karsten
karsten dot jursch at fleiheit dot com
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: convert -crop ... fails on png files

Post by magick »

To fix the problem you reported, use this command to reset the virtual canvas of your image:
  • convert 20080331091752540734_mx.png +repage -crop 3988x572+0+0 20080331091752540734_bo.png
janilrau

Re: convert -crop ... fails on png files

Post by janilrau »

ok, thanks a lot I'll try this, but I don't understand the difference in positioning the image on a virtula canvas between PNG and JPG.

Does it mean, that my JPG code (that works fine) is wrong?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: convert -crop ... fails on png files

Post by magick »

Post Reply