File reading wildcards

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
martron

File reading wildcards

Post by martron »

I'm trying convert a series of images using the syntax I found on http://www.imagemagick.org/Usage/files/ . I'm running ImageMagick 6.5.1-0 2009-08-27 Q16 OpenMP on Ubuntu Karmic.

When I run the following:

Code: Select all

convert '2010030613%02d.jpg[51-72]' wiarton.jpg
I expect that it will simply rename the chosen images to wiarton-0.jpg, wiarton-1.jpg. When run, it chooses the right files and does indeed rename them but also resizes them to 324x243. The original images are 2592x1944 and I want them to stay that way when I run the command. I think the input resize modifier might be interpreting the image sequence as resize information.

For example, if I run:

Code: Select all

convert '2010030613%02d.jpg[51-53]' wiarton.jpg
(only convert from images 51-53)
the images are resized to 1296x972.

Am I missing something about the file read modifiers? Why is this resizing happening and how can I stop it?

Thanks.
martron

Re: File reading wildcards

Post by martron »

I just ran another test and it seems as though the number of images decides what size the output will be. In other words, when converting 3 images, using [51-53] and [66-68] end up with the same size output.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: File reading wildcards

Post by fmw42 »

jpg format does not support frames as indicated by [#-##]. This syntax is only for multiframe images such as a gif animation or pages of pdf or multiframe tif.

If you have a series of image, you will need to specify each image you have. If the images are named with image-0.jpg ... image-N.jpg, then you can write a loop to process just the ones you want. There is no wildcard except for all (*) that I know about that you can use with non-frame input images.

Perhaps someone else knows more about this and can suggest another solution.
martron

Re: File reading wildcards

Post by martron »

At http://www.imagemagick.org/Usage/files/#read_frames after showing how to read frames of an image it also states:
You can also get IM to read images based on a list of numbers. For example..

Code: Select all

convert 'image_%03d.png[5-7]' ...
will read in the files "image_005.png", "image_006.png", and "image_007.png". With this method you can not use a negative index.
I think I'm doing that part correctly, and indeed the proper sequence of images are read. The only real problem is that they are also resized.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: File reading wildcards

Post by fmw42 »

martron wrote:At http://www.imagemagick.org/Usage/files/#read_frames after showing how to read frames of an image it also states:
You can also get IM to read images based on a list of numbers. For example..

Code: Select all

convert 'image_%03d.png[5-7]' ...
will read in the files "image_005.png", "image_006.png", and "image_007.png". With this method you can not use a negative index.
I think I'm doing that part correctly, and indeed the proper sequence of images are read. The only real problem is that they are also resized.

I am very surprised that this works. The page your reference says:

"Will select specific sub-frames from a multi-image file format from the image that has been read in"

jpg and png do NOT support multi-image file formats.

However, testing does show that this does work. So I learn something new today.

Testing:

convert rose: netscape: logo: rose: netscape: logo: tmp_%d.png

convert tmp_%d.png[2-4] tmpnew.jpg

produces the correct size resulting images, tmpnew-0.jpg tmpnew-1.jpg tmpnew-2.jpg

(IM 6.6.0-5 Q16 Mac OSX Tiger)

Again, try upgrading your IM version.

But try removing the quotes around your image names.
Last edited by fmw42 on 2010-03-09T11:18:20-07:00, edited 1 time in total.
martron

Re: File reading wildcards

Post by martron »

I think the document meant that "in addition to reading subframes from multi-image files, you can also You can also get IM to read image file based on a list of numbers."
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: File reading wildcards

Post by fmw42 »

see my edited comments above
martron

Re: File reading wildcards

Post by martron »

I managed to compile 6.6 on ubuntu and now it all works as expected. Thanks!
Post Reply