error in crop attempt (geometry does not contain image)

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
learn
Posts: 1
Joined: 2014-10-21T13:06:24-07:00
Authentication code: 6789

error in crop attempt (geometry does not contain image)

Post by learn »

(sorry, inadvertently hit a key earlier and submitted and unfinished post! Here's the full one) --

I am very new to ImageMagick, so I apologize if this is too simple but here goes:

The command below is being automatically generated by some code that was handed to me. It is generating the error seen below.

$ convert -depth 8 -rotate 0 -density 144 -crop 19171.3x19171+9611.25+-29424.9 /tmp/tiffcap3_0001.ps tiff:/tmp/tiffcap3_0001.tiff
convert: geometry does not contain image `/tmp/tiffcap3_0001.ps' @ warning/transform.c/CropImage/666.
convert: TIFF: negative image positions unsupported /tmp/tiffcap3_0001.tiff @ error/tiff.c/WriteTIFFImage/3317

From what I read in the ImageMagick pages, the x-offset (9611.25) is the offset measured downward from the top-left corner and the y-offset(-29424.9) is the offset measured to the right from the top-left corner. In this case, I assume it is to the left since it is negative, and would go way off image, being so big.
When I run ghostscript on this image, it looks AOK. I assume the x and y offsets are to just capture the image and leave out axes, title, etc., but it looks like these automatically calculated offsets are way off for some reason. Somehow I need to manually figure out what the offsets should really be. Does anyone know the best way for me to do that (i.e., how many points down and to the right from the upper-left corner of the full image, is the sub-image I need?)



Some notes --
running identify yields:
$ ~/IMAGEMAGICK/bin/identify /tmp/tiffcap3_0001.ps
/tmp/tiffcap3_0001.ps PNG 612x764 612x764+0+0 16-bit sRGB 197KB 0.000u 0:00.000

I read on this site that adding +repage can fix things, but it didn't help.
$ convert -depth 8 -rotate 0 -density 144 -crop 19171.3x19171+9611.25+-29424.9 +repage /tmp/tiffcap3_0001.ps tiff:/tmp/tiffcap3_0001.tiff
convert: geometry does not contain image `/tmp/tiffcap3_0001.ps' @ warning/transform.c/CropImage/666.

thanks for any pointers regarding the best way to determine what my offsets (x and y) should really be.
Last edited by learn on 2014-10-21T13:39:47-07:00, edited 1 time in total.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: error in crop attempt (geometry does not contain image)

Post by Bonzo »

The order of your code is not correct which may be the problem; You read the image in first before operating on it. I would try this:

Code: Select all

$ convert /tmp/tiffcap3_0001.ps +repage -depth 8 -rotate 0 -crop 19171.3x19171+9611.25+-29424.9 -density 144  tiff:/tmp/tiffcap3_0001.tiff
-rotate 0 is not doing anything; are depth and density the settings for the input image or the output image?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: error in crop attempt (geometry does not contain image)

Post by snibgo »

The input image is (apparently) only 612 pixels wide. The code takes the top-left position of the crop starting at pixel 9611.25. This is outside the input. Hence the "geometry does not contain image" warning. It is just a warning; an output is created.

There are other problems. Tiff files can't store negative offsets. This is fixed by "+repage", which removes offsets.

The command is very old syntax; the "-crop" should come after the input image, not before.
snibgo's IM pages: im.snibgo.com
Post Reply