Page 1 of 1

convert problem

Posted: 2008-06-20T12:53:45-07:00
by dontry
hi all, i use 6.4.1 version of ImageMagick and get this error while try crop on a png image:
convert: no pixels defined in cache 'file.png'

i don't receive this error for all image anyone does know why?

Re: convert problem

Posted: 2008-06-20T13:11:09-07:00
by fmw42
best think would be to show us your exact command line and provide a link to your input image

Re: convert problem

Posted: 2008-06-20T13:53:49-07:00
by dontry
the command is:

Code: Select all

convert image.png -crop 1x0!+10+0 out.png
the image is a simply image with a white background and a writted in black.

Re: convert problem

Posted: 2008-06-20T14:45:27-07:00
by magick
What is the width / height of your image?

Re: convert problem

Posted: 2008-06-20T14:52:33-07:00
by dontry
120x60

Re: convert problem

Posted: 2008-06-20T15:38:57-07:00
by fmw42
convert image.png -crop 1x0!+10+0 out.png
The problem is that you are telling -crop that you want zero rows. You need to write this as

onvert image.png -crop 1x1+10+0 out.png

That will get you a 1x1 pixel image starting at x=10 and y=0

Image coordinates are indexed from 0, but the width and height must be at least 1 pixel.

Re: convert problem

Posted: 2008-06-20T15:57:22-07:00
by dontry
thx man :) now it's all ok

Re: convert problem

Posted: 2008-06-21T01:27:51-07:00
by dontry
i get the same error today :( anyone have ideas?

Re: convert problem

Posted: 2008-06-21T02:15:28-07:00
by dontry
is there an option to give to convert such that convert doesn't block on error of this kind?because when i receive this error the program wait for a signal on shell...thx in advance

Re: convert problem

Posted: 2008-06-21T03:22:29-07:00
by dontry
i try to get -debug "Exception" and this is the output:

2008-06-21T12:27:08+02:00 0:01 0.010u 6.4.1 Exception convert[15247]: png.c/unknown/1390/Exception
Image width or height is zero in IHDR `5048.png'
2008-06-21T12:27:08+02:00 0:01 0.010u 6.4.1 Exception convert[15247]: png.c/unknown/2882/Exception
Corrupt image `5048.png'
2008-06-21T12:27:08+02:00 0:01 0.010u 6.4.1 Exception convert[15247]: convert.c/unknown/2651/Exception
missing an image filename `1.jpg'

Re: convert problem

Posted: 2008-06-21T03:24:55-07:00
by dontry
in /libpng-1.2.8/pngset.c there's:

if (width == 0 || height == 0)
png_error(png_ptr, "Image width or height is zero in IHDR");

Re: convert problem

Posted: 2008-06-21T11:07:19-07:00
by fmw42
It looks like you are getting your width and height from some header information that may be returning zero. So you can extract the width and height and in a shell script test for 0 and change to 1.

width=however you are getting it from the header
height=however you are getting it from the header
width=`convert xc: -format "%[fx:max($width,1)]" info:`
height=`convert xc: -format "%[fx:max($height,1)]" info:`

Or do the same using our API if you are using one.

then

convert image.png -crop ${width}x${height}+10+0 out.png

Re: convert problem

Posted: 2008-06-29T23:05:16-07:00
by anthony
If width or height is zero in a crop, it is suposed to use the width or height of the virtual canvas.

see Strip Cropping....
http://imagemagick.org/Usage/crop/#crop_strip

Though combining this with '!' may be the cause of the problem, as it may be trying to use zero for the 'viewport' aspect the '!' enables.

That is the bug!