How do I use convert -extract

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
mcanedo

How do I use convert -extract

Post by mcanedo »

Hi:
I'm trying to simply extrat an area from an image, I use a command like:

Code: Select all

convert -extract 100x100 origen.png destino.png
but the resulting file is exactly the same than the original.
Am I using a wrong syntax??

I found this bug comment, but with no comments, so I don't know if I'm writing wrong (I'm completly new to ImageMagick)....

http://redux.imagemagick.org/discussion ... 971#p28971
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: How do I use convert -extract

Post by el_supremo »

Try forcing the x,y coordinate to zero with
-extract 100x100+0+0

Wizards:
When I tested this with 100x100, I either get the fullsized image or one that has been reduced to no larger than 100x100.
My guess is that the geometry isn't being initialized to zero in ReadImage in constitute.c

Pete
mcanedo

Re: How do I use convert -extract

Post by mcanedo »

Forcing did not worked either,
I solve my problem using

Code: Select all

convert -crop
Do crop and extract are the same?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How do I use convert -extract

Post by anthony »

no they are not -extract is a stream processing option that may not work with all image formats. -crop works on the image that was completely read into memory.

WARNING: crop also preverves the images 'offset' meta-data on the virtual canvas. Some formats save that info, and it can effect other operations. I suggest if you don't care about the offset you add +repage after the -crop.

See http://www.imagemagick.org/Usage/crop/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply