Timestamp out of filename

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

Re: Timestamp out of filename

Post by snibgo »

You need a space before and after every \( and \) .
snibgo's IM pages: im.snibgo.com
max2331
Posts: 7
Joined: 2016-09-07T04:08:38-07:00
Authentication code: 1151

Re: Timestamp out of filename

Post by max2331 »

Thank you, now it works.

But one more thing:

I tried for another action

Code: Select all

composite 2016081711230002dBuZ.ppi_top.png -set filename:f "%[t]" -gravity center Background_final.png "%[filename:f]_2.png"
On the HP of Imagemagick it says that composite knows how to deal with -set but i get:

unrecognized option -set @ error/composite.c/CompositeImageCommand/1438

I make several steps with 2016081711230002dBuZ.ppi_top.png and always want to keep the filename similar, just with an _1 or _2 at the end.
How can i do this?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Timestamp out of filename

Post by snibgo »

I never use "composite". It can't do anything that "convert" can do, and "convert" is maintained better.
snibgo's IM pages: im.snibgo.com
max2331
Posts: 7
Joined: 2016-09-07T04:08:38-07:00
Authentication code: 1151

Re: Timestamp out of filename

Post by max2331 »

Thank you
This works so far

Code: Select all

convert Background_final.png 2016081711230002dBuZ.ppi_top.png -set filename:f "%[t]"  -gravity center -composite "%[filename:f]_2.png"
But how can i tell to read the second filename? now my output is:
Background_final_2.png but i want 2016081711230002dBuZ.ppi_top_2.png
But if i change it, the background will be on top.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Timestamp out of filename

Post by GeeMack »

max2331 wrote:But how can i tell to read the second filename?
I'm not sure I understand, but it looks like you want the output file name to come from the second input file. That "%[filename:f]" variable doesn't always behave the way you might expect, so I use a workaround like this...

Code: Select all

convert Background_final.png \
   \( 2016081711230002dBuZ.ppi_top.png -set option:fname "%[t]" \) \
   -composite -set filename:f "%[fname]" "output_%[filename:f].png"
That isolates your second input file in parentheses and puts its name into a variable. I made up the name "fname". It can be anything. Then just before the final output, feed that variable into your "%[filename:f]" variable. I know it looks a little clumsy, but that's the most reliable way I've found to make it work.
Post Reply