Zero padded image names

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
daviddoria

Zero padded image names

Post by daviddoria »

If I have images 1.jpg, 2.jpg ... 5.jpg, I can do this

Code: Select all

#convert [1-5].jpg +append append.jpg
But if I have images 001.jpg, 002.jpg ... 005.jpg, the above does not work, and the following also does not work.

Code: Select all

convert [001-005].jpg +append append.jpg
Is there a way to do that? (I have more than 5 images, so 00[1-5].jpg is not the answer! haha)

Thanks,

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

Re: Zero padded image names

Post by anthony »

From raw notes in IM Examples, File Handling, Read Modifiers
http://www.imagemagick.org/Usage/files/#read

Code: Select all

convert 'image_%03d.png[5-7]' ...
The %03d specifys insert the numbers as 3 zero padded digits (See man page for the "printf()" function.

NOTE this is NOT a command line shell construct but a IM construct, so you need to quote the
input filename.


The [5-7].jpg construct is a shell expandsion, and not done by IM itself. The shell replaces it with 5.jpg 6.jpg 7.jpg if those files exists.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
daviddoria

Re: Zero padded image names

Post by daviddoria »

Great, thanks.
Post Reply