new file name from source file name

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
Okeebc
Posts: 2
Joined: 2011-03-12T07:33:01-07:00
Authentication code: 8675308

new file name from source file name

Post by Okeebc »

Is there a way to use the file name of the source file to name the new file? For instance:

convert freeport.jpg -color 127 (?).png

where (?) is the command to use the source file name, in this case freeport.

Thanks in advance.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: new file name from source file name

Post by fmw42 »

try

convert freeport.jpg -set filename:original %t -colors 127 %[filename:original].png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: new file name from source file name

Post by anthony »

See... IM Examples, Saving Images, Filename Escapes.
http://www.imagemagick.org/Usage/files/#save_escapes

NOTE this also provides a way of using convert in a montage type situation. Though convert will always read in all images
into memory, where mogrify handles them one image at a time.
The "convert" alternative to "mogrify"
http://www.imagemagick.org/Usage/basics ... fy_convert

I only added that example a couple of days ago, so it is good timing!

.Just one word of warning, do not include the file suffix in the filename setting! IM will not see it and save it using the original file format, rather than a posibly different one that was set in the in the filename setting.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Okeebc
Posts: 2
Joined: 2011-03-12T07:33:01-07:00
Authentication code: 8675308

Re: new file name from source file name

Post by Okeebc »

Thanks guys! :D
Post Reply