Cropped PNG is blank.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
arizonagroovejet
Posts: 28
Joined: 2009-01-20T12:37:52-07:00

Cropped PNG is blank.

Post by arizonagroovejet »

I create a PNG.

Code: Select all

$ convert -background transparent -fill black -gravity center -size 1680x1050 -font Arial-Bold caption:"HAPPY\nBIRTHDAY"  happybirthday.png
The result is a PNG image 1680x1050 with black text on a transparent background.

Then I crop the image.

Code: Select all

$ convert happybirthday.png -gravity center -crop 500x500+0+0 +repage happyfoo.png
What I expect to get is a 500x500 PNG that contains the middle 500x500 pixels of happybirthday.png. What I actually get is a 500x500 PNG that is entirely transparent.

Can anyone explain why I get an entirely transparent image and how to get the expect result?


Version: ImageMagick 6.6.7-1 2011-02-05 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP OpenCL

Installed using MacPorts on

ProductName: Mac OS X
ProductVersion: 10.6.6
BuildVersion: 10J567
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Cropped PNG is blank.

Post by fmw42 »

I can confirm your results on IM 6.6.7.7 Q16 Mac OSX Tiger.

But keep in mind that PNG has been undergoing quite some changes over the last number of releases and still has some bugs to be fixed that glennrp is working hard to continue to fix. see http://www.imagemagick.org/script/changelog.php

In the meantime, this works.

convert happybirthday.png -gravity center -crop 500x500+0+0 +repage PNG32:happyfoo.png
Post Reply