convert problem
convert problem
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?
convert: no pixels defined in cache 'file.png'
i don't receive this error for all image anyone does know why?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert problem
best think would be to show us your exact command line and provide a link to your input image
Re: convert problem
the command is:
the image is a simply image with a white background and a writted in black.
Code: Select all
convert image.png -crop 1x0!+10+0 out.png
Re: convert problem
What is the width / height of your image?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert problem
The problem is that you are telling -crop that you want zero rows. You need to write this asconvert image.png -crop 1x0!+10+0 out.png
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
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
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'
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
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");
if (width == 0 || height == 0)
png_error(png_ptr, "Image width or height is zero in IHDR");
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert problem
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
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
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: convert problem
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!
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/
https://imagemagick.org/Usage/