convert problem

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
dontry

convert problem

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert problem

Post by fmw42 »

best think would be to show us your exact command line and provide a link to your input image
dontry

Re: convert problem

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

Re: convert problem

Post by magick »

What is the width / height of your image?
dontry

Re: convert problem

Post by dontry »

120x60
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert problem

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

Re: convert problem

Post by dontry »

thx man :) now it's all ok
dontry

Re: convert problem

Post by dontry »

i get the same error today :( anyone have ideas?
dontry

Re: convert problem

Post 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
dontry

Re: convert problem

Post 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'
dontry

Re: convert problem

Post 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");
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert problem

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: convert problem

Post 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!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply