Page 1 of 1

%d escape problem when used with Image Property Percent Escapes

Posted: 2019-02-07T13:18:12-07:00
by robin217
Minimal example that exhibits the problem:

Code: Select all

convert rose: 'rose_%d.png'
# Resulting filename: rose_0.png (as expected)

convert rose: -set filename:mysize "%wx%h" 'rose_%[filename:mysize]_%d.png'
# Resulting filename: rose_70x46_%d0.png
# Why is '%d' in the output filename?
# Expected: rose_70x46_0.png

convert rose: -set filename:mysize "%wx%h" 'rose_%d_%[filename:mysize].png'
# Resulting filename: rose70x46.png
# Expected: rose_0_70x46.png
Relevant documentation: https://www.imagemagick.org/Usage/files/#save_escapes

Re: %d escape problem when used with Image Property Percent Escapes

Posted: 2019-02-07T15:22:13-07:00
by fmw42
You cannot do that, currently, as far as I know. You can reverse the order and put %d first, I think. Best solution can be found at https://stackoverflow.com/questions/545 ... 2#54582542

Code: Select all

convert rose: wizard: -set filename:mysize "%wx%h_%p" rose_%[filename:mysize].png
#=> rose_70x46_0.png rose_480x640_1.png

However, I do not think you can add leading zeros to %p.

Re: %d escape problem when used with Image Property Percent Escapes

Posted: 2019-02-07T17:24:23-07:00
by robin217
OK, thank you.