Using the "*" character: order of images

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
Jean-Pierre Coulon
Posts: 41
Joined: 2016-10-04T02:08:22-07:00
Authentication code: 1151
Location: Nice, France

Using the "*" character: order of images

Post 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?
mikmach
Posts: 42
Joined: 2015-02-06T07:50:43-07:00
Authentication code: 6789

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

Post 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.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

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

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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.
snibgo's IM pages: im.snibgo.com
Jean-Pierre Coulon
Posts: 41
Joined: 2016-10-04T02:08:22-07:00
Authentication code: 1151
Location: Nice, France

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

Post 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.
Jean-Pierre Coulon
Posts: 41
Joined: 2016-10-04T02:08:22-07:00
Authentication code: 1151
Location: Nice, France

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

Post 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.
Post Reply