Page 1 of 1

Using the "*" character: order of images

Posted: 2016-10-04T02:17:45-07:00
by Jean-Pierre Coulon
Suppose I have a set of tif images called p1.tif, p2.tif... p25. tif. If I type convert p*.tif mybook.pdf, how does ImageMagick choose the order of these images in the pdf result? Is it the same order you obtain when you type dir p*.tif in a command prompt window? Can I influence this order?

Re: Using the "*" character: order of images

Posted: 2016-10-04T07:09:59-07:00
by mikmach
'*' is resolved by your shell, not ImageMagick. So, yes, it should be the same order as it is returned by 'dir p*.tif'. This order will be different on various systems, various shells etc.

Re: Using the "*" character: order of images

Posted: 2016-10-04T07:25:03-07:00
by GeeMack
Jean-Pierre Coulon wrote:Suppose I have a set of tif images called p1.tif, p2.tif... p25. tif. If I type convert p*.tif mybook.pdf, how does ImageMagick choose the order of these images in the pdf result? Is it the same order you obtain when you type dir p*.tif in a command prompt window? Can I influence this order?
I don't know if IM has a built-in method for specifying the order of input files called with wildcards. I don't think it has, but some more qualified experts might weigh in. There are some fairly simple ways to get your files into IM in a particular order, but the specifics depend on your operating system and possibly the version of IM you're using. You should always provide those when asking questions to get the best answers.

I'm using ImageMagick 7.0.3 on a Windows 10 system, so a simple way to specify the order of input files is to do a directory listing in my preferred order and redirect it to a text file. Recent versions of ImageMagick will read the input names from that file by prefixing the file name with a "@". Let's say the list of images is in a file named "imagelist.txt", the command would start with something like this...

Code: Select all

magick @imagelist.txt -resize 640x480 ...
If you're running IM in a *nix shell you have other options like putting the directory listing command in backticks right inside the IM command. Let us know your OS, your version of IM, and more particularly what you'd like to accomplish and you can get some better answers.

Re: Using the "*" character: order of images

Posted: 2016-10-04T08:31:39-07:00
by snibgo
Jean-Pierre Coulon wrote:... a set of tif images called p1.tif, p2.tif... p25. tif.
It's often useful to use leading zeros, so the files are called p01.ti, p02.tif... p25.tif. That way, an alphabetic order can be used.

Re: Using the "*" character: order of images

Posted: 2016-10-04T09:37:08-07:00
by Jean-Pierre Coulon
Thanks, it works well with leading zeroes. I am with Windows 10. The order in the pdf is that obtained with dir/on p*.tif.

Re: Using the "*" character: order of images

Posted: 2016-10-04T09:38:00-07:00
by Jean-Pierre Coulon
Thanks, it works well with leading zeroes. I am with Windows 10. The order in the pdf is that obtained with dir/on p*.tif.