Batch rename with image dimensions

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?".
NITO
Posts: 33
Joined: 2019-12-31T17:28:13-07:00
Authentication code: 1152
Location: Brasil - São Paulo

Re: Batch rename with image dimensions

Post by NITO »

what should this loop script look like? ... what about the fact that it does not correctly follow a single pdf with multiple pages?

NITO
Posts: 33
Joined: 2019-12-31T17:28:13-07:00
Authentication code: 1152
Location: Brasil - São Paulo

Re: Batch rename with image dimensions

Post by NITO »

what should this loop script look like? ... what about the fact that it does not correctly follow a single pdf with multiple pages?

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch rename with image dimensions

Post by fmw42 »

Test this on one image not as a .bat file, but just in the CMD window. Change as needed for Windows. If it does not work, then post a link to your PDF.

Code: Select all

magick image.pdf -set filename:mysize "%wx%h" "%[filename:mysize]_%d.png"
Sorry, I do not use Windows and so cannot tell you how to script it in .bat.

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

Re: Batch rename with image dimensions

Post by anthony »

If you percents are needing to be doubled you are on a Windows system or some language or construct where they use % (like the Printf() format string).

As for batch processing see...
http://www.imagemagick.org/Usage/basics ... fy_convert
And for Windows...
http://www.imagemagick.org/Usage/windows/#for_loops

HOWEVER Be warned that processing PDF's with ImageMagic is generally a BAD IDEA.
It is a Vector Image file format, and having IM read and write such a file can change it!
http://www.imagemagick.org/Usage/formats/#vector
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

Locked