Operate on just one image in an image list?

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
rling
Posts: 7
Joined: 2007-10-07T16:21:15-07:00

Operate on just one image in an image list?

Post by rling »

Hello
I want to use IM to separate an RGB image into three greyscale images, resize the channels independently and then recombine them. I'd like to do it in one command line if possible. Is it possible to select that the -resize operator only applies to a selected one of the images?

For example, using an imaginary operator "-select":

convert foo.jpg -separate -select 1 -resize 100x100 -select 2 -resize 150x150 -select 3 -resize 200x200 -combine foo2.jpg

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

Re: Operate on just one image in an image list?

Post by fmw42 »

you can use clone and parenthesis processing (see http://www.imagemagick.org/Usage/basics/#image_seq )

BUT you cannot recombine (-combine) the images if they are not the same size. So you would have to pad them back to the same size first.


convert zelda3.png -separate \
\( -clone 0 -resize 75% -gravity center -background black -extent 128x128 \) \
\( -clone 1 -resize 50% -gravity center -background black -extent 128x128 \) \
\( -clone 2 -resize 25% -gravity center -background black -extent 128x128 \) \
-delete 0-2 -combine zelda3_tmp.png
rling
Posts: 7
Joined: 2007-10-07T16:21:15-07:00

Re: Operate on just one image in an image list?

Post by rling »

Lovely. Thankyou.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Operate on just one image in an image list?

Post by anthony »

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