-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
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

-extract

Post by rmabry »

In the command-line -options doc, under -extract, the following is missing a single quotation mark:
convert -size 16000x16000 -depth 8 image.rgb[640x480+1280+960]' image.rgb image.png
Actually, I find the examples given for this to be unnecessarily complicated for the typical extract operation. Here's the entire entry:
-extract width
-extract widthxheight{{+-}offset}

extract the specified area from image. The option is most useful for extracting a subregion of a very large raw image. Note, these two command are equivalent:

convert -size 16000x16000 -depth 8 -extract 640x480+1280+960 image.rgb image.png
convert -size 16000x16000 -depth 8 image.rgb[640x480+1280+960]' image.rgb image.png
The examples above produce multiple images. How about something simpler, like this?

convert -extract 640x480+1280+960 bigImage.rgb extractedImage.rgb
convert 'bigImage.rgb[640x480+1280+960]' extractedImage.png
The option's form -extract width does not give an extracted image for me, just a resized one. I'm not sure what such a form should reasonably be expected to do, though.

Finally, I am confused by the results of the following two commands, which I guess means I am confused about -geometry, in general:
convert -extract x55+0+0 logo: horizontalWiz.png
convert -extract 55x+0+0 logo: verticalWiz.png
The first gives something I expect, a horizontal extraction of dimensions 640x55 from the top of the logo, the width coming from that of the input image (logo, 640x480). So I'd like the second to give me a vertical strip with dims 55x480, but it gives an error, "convert: geometry does not contain image `LOGO'."

If I use "48" in place of "48x" I get an " invalid argument" error.

Rick
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: -extract

Post by el_supremo »

Code: Select all

convert -extract 55x+0+0 logo: verticalWiz.png
works for me with IM 6.4.4 on Win XP

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Re: -extract

Post by rmabry »

el_supremo wrote:

Code: Select all

convert -extract 55x+0+0 logo: verticalWiz.png
works for me with IM 6.4.4 on Win XP

Pete
Ha! This is me, also on XP: Version: ImageMagick 6.4.5 2008-10-24 Q16

It gives the error,

convert: geometry does not contain image `LOGO'.

Exactly the same for Version: ImageMagick 6.4.4 2008-10-19 Q16 on Linux.

Can someone else report?

Thanks, Pete.

Rick
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: -extract

Post by magick »

We tried ImageMagick 6.4.6-5 under Windows and the extract option worked properly without complaint.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: -extract

Post by Bonzo »

Worked OK for me without an error as well - Windows XP
If I use "48" in place of "48x" I get an " invalid argument" error.
I pressume you are getting an error as this is the widthxheight if you leave either the width or the height out there is a default setting but you can not leave the x out as the code must be looking for it.
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Re: -extract

Post by rmabry »

Bonzo wrote:Worked OK for me without an error as well - Windows XP
Strange. Thanks for trying it. You didn't mention which version you're using, but I now suspect it won't matter!
If I use "48" in place of "48x" I get an " invalid argument" error.
I pressume you are getting an error as this is the widthxheight if you leave either the width or the height out there is a default setting but you can not leave the x out as the code must be looking for it.
Well, this option is not one I want, but I did want to mention it. I'm getting it, as I said, from this part of the doc for -extract:

-extract width
-extract widthxheight{{+-}offset}

I'm trying (again) to figure out this x business. Using x48 makes sense to me. Therefore, using 48x does, too. My experiments with it give errors, so I'd hoped a bare 48 was intended for what I thought 48x would do.

Sheesh.

Rick
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: -extract

Post by magick »

We get the correct results with this command:
  • convert -extract 48x+100+100 logo: x:
When the height is missing it substitutes the image height. So in this example the extract argument given is the same as 48x580+100+100. Note that the above command is equivalent to this command:
  • convert 'logo:[48x+100+100]' x:
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Re: -extract

Post by rmabry »

magick wrote:We get the correct results with this command:
  • convert -extract 48x+100+100 logo: x:
Not me. Not on WinXP 6.4.5 nor on 6.4.4 Linux.
When the height is missing it substitutes the image height. So in this example the extract argument given is the same as 48x480+100+100. Note that the above command is equivalent to this command:
  • convert 'logo:[48x+100+100]' x:
Thanks, and I understand what should happen. And this is, in part, academic, since I can work around these issues. But just for the record, the command above fails likewise for me at present.

convert: geometry does not contain image `LOGO'.

This works:

convert 'logo:[48x480+100+100]' wiz.png

Weird, weird, weird.

I appreciate all the trouble you've taken.

Rick
Post Reply