%d escape problem when used with Image Property Percent Escapes

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
robin217
Posts: 2
Joined: 2019-02-07T13:12:30-07:00
Authentication code: 1152

%d escape problem when used with Image Property Percent Escapes

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
robin217
Posts: 2
Joined: 2019-02-07T13:12:30-07:00
Authentication code: 1152

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

Post by robin217 »

OK, thank you.
Post Reply