Reading only first layer

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
bondu
Posts: 1
Joined: 2011-11-04T15:37:04-07:00
Authentication code: 8675308

Reading only first layer

Post by bondu »

I need to read a file into imagemagick via the cli, and only work with the first image in the sequence.

There are two options:
convert 'foo.gif[0]' foo.jpg
convert -delete 1--1 foo.gif foo.jpg

Is there any real difference between them? or is there another optimized way to read in just the single image in the sequence?

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

Re: Reading only first layer

Post by anthony »

bondu wrote:I need to read a file into imagemagick via the cli, and only work with the first image in the sequence.

There are two options:

Code: Select all

convert 'foo.gif[0]' foo.jpg
convert -delete 1--1 foo.gif foo.jpg
Is there any real difference between them? or is there another optimized way to read in just the single image in the sequence?

thanks
-daniel
I am not actually sure if the first example actually reads all images into memory before selecting frames. That area of the code is a convoluted, and I have not followed it through fully.

I'll forward this question to Magick who is probably the only one who can answer.

NOTE for second line of code... You should read the images in before trying to delete them :-)

Code: Select all

    convert foo.gif -delete 1--1 foo.jpg
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply