identify fails silently on filenames with %d
identify fails silently on filenames with %d
"identify" on linux {ubuntu 12.10 amd64 3.5.0-13-generic} doesnt output anything on filenames that have "%d" in them.
/tmp/a$ md5sum *
0115516fc61d2d1e6f094c22ac95051e a-d.png
0115516fc61d2d1e6f094c22ac95051e a%d.png
/tmp/a$ identify a-d.png
a-d.png PNG 80x80 80x80+0+0 8-bit DirectClass 581B 0.000u 0:00.000
/tmp/a$ identify a%d.png
/tmp/a$ identify a-d.png
a-d.png PNG 80x80 80x80+0+0 8-bit DirectClass 581B 0.000u 0:00.000
/tmp/a$ identify --version
Version: ImageMagick 6.7.7-10 2012-08-17 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP
/tmp/a$ md5sum *
0115516fc61d2d1e6f094c22ac95051e a-d.png
0115516fc61d2d1e6f094c22ac95051e a%d.png
/tmp/a$ identify a-d.png
a-d.png PNG 80x80 80x80+0+0 8-bit DirectClass 581B 0.000u 0:00.000
/tmp/a$ identify a%d.png
/tmp/a$ identify a-d.png
a-d.png PNG 80x80 80x80+0+0 8-bit DirectClass 581B 0.000u 0:00.000
/tmp/a$ identify --version
Version: ImageMagick 6.7.7-10 2012-08-17 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: identify fails silently on filenames with %d
Did you try putting the filename in quotes. Also perhaps upgrade your version of IM.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: identify fails silently on filenames with %d
The %d is a special interpretation (both read and write).
Use %%d instead.
I have a plan to add a 'security option' in IMv7 to disable various filename modifications IM does, such as this. (another is the the coder prefix handling). That is make tell IM to treat filenames and perhaps arguments as being more 'literal', especially in IMv7 where % escapes are also used for almost ALL arguments (operation arguments already do this in "magick")
Use %%d instead.
I have a plan to add a 'security option' in IMv7 to disable various filename modifications IM does, such as this. (another is the the coder prefix handling). That is make tell IM to treat filenames and perhaps arguments as being more 'literal', especially in IMv7 where % escapes are also used for almost ALL arguments (operation arguments already do this in "magick")
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: identify fails silently on filenames with %d
Yes, i tried quoting the files, but you realize, thats handled by the SHELL, not by imagemagick; imagemagick receives the argument as the SAME STRING whether its quoted or not. {% is not special in bash.}
thanks for the help, but this is actually a bug, not my shell interpolation misunderstanding.
as for the %d's being legitimate escapes in the filename, no, thats not true, and %% doesnt help it.
heres a table of what works and doesnt {quoted, or unquoted, or escaped}, extracted from my code below:
WORKS:
a.png
a
%
d%
a%!d.png
a%b.png
DOES NOT WORK:
a%d.png
a%%d.png
a%d
%da
%d
%%d
%d.png
here is the output proving that shell interpolation and quoting of arguments is NOT the problem:
here is the output showing that %% doesnt help:
here is the output showing what WORKS and what does NOT work:
thanks for the help, but this is actually a bug, not my shell interpolation misunderstanding.
as for the %d's being legitimate escapes in the filename, no, thats not true, and %% doesnt help it.
heres a table of what works and doesnt {quoted, or unquoted, or escaped}, extracted from my code below:
WORKS:
a.png
a
%
d%
a%!d.png
a%b.png
DOES NOT WORK:
a%d.png
a%%d.png
a%d
%da
%d
%%d
%d.png
here is the output proving that shell interpolation and quoting of arguments is NOT the problem:
Code: Select all
wolke:/tmp/a$ cp a.png a%d.png
wolke:/tmp/a$ identify a.png
a.png PNG 80x80 80x80+0+0 8-bit DirectClass 8.59KB 0.000u 0:00.000
wolke:/tmp/a$ identify a%d.png
wolke:/tmp/a$ identify 'a%d.png'
wolke:/tmp/a$ identify a\%d.png
wolke:/tmp/a$ identify "a%d.png"
wolke:/tmp/a$ identify "a%d.png"
wolke:/tmp/a$ identify a.png
a.png PNG 80x80 80x80+0+0 8-bit DirectClass 8.59KB 0.000u 0:00.000
Code: Select all
wolke:/tmp/a$ cp a.png a%d.png
wolke:/tmp/a$ identify a.png
a.png PNG 80x80 80x80+0+0 8-bit DirectClass 8.59KB 0.000u 0:00.000
wolke:/tmp/a$ identify a%%d.png
wolke:/tmp/a$ identify a.png
a.png PNG 80x80 80x80+0+0 8-bit DirectClass 8.59KB 0.000u 0:00.010
here is the output showing what WORKS and what does NOT work:
Code: Select all
wolke:/tmp/a$ for x in a%d.png a%\!d.png a %%d %d.png a%b.png %da % a%%d.png d% a%d %d
> do
> cp a.png $x
> identify $x | grep PNG > /dev/null && echo GOOD: $x || echo BAD: $x
> done
BAD: a%d.png
GOOD: a%!d.png
GOOD: a
BAD: %%d
BAD: %d.png
GOOD: a%b.png
BAD: %da
GOOD: %
BAD: a%%d.png
GOOD: d%
BAD: a%d
BAD: %d
Re: identify fails silently on filenames with %d
also, as for the version: 2012-08-17 is recent enough, yes?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: identify fails silently on filenames with %d
This works on IM 6.7.9.3 Q16, though without the -verbose it still returns no informaton:
identify -verbose 1%d.jpg
Also creating my own script with specific string format returns the information I requested.
ids 1%d.jpg
1%d.jpg[0] DirectClass sRGB channels=srgb depth=8 min=0 max=1 mean=0.649543 std=0.300478 117501B bytes
identify -verbose 1%d.jpg
Also creating my own script with specific string format returns the information I requested.
ids 1%d.jpg
1%d.jpg[0] DirectClass sRGB channels=srgb depth=8 min=0 max=1 mean=0.649543 std=0.300478 117501B bytes
Last edited by fmw42 on 2012-09-04T20:18:38-07:00, edited 1 time in total.
Re: identify fails silently on filenames with %d
oh snap, me too. ok, so its an error on the output somehow. thanks for that! i now have a solution to the problem immediately at hand.fmw42 wrote:This works on IM 6.7.9.3 Q16, though without the -verbose it still returns no informaton:
identify -verbose 1%d.jpg
Re: identify fails silently on filenames with %d
just to be crystal clear, THIS IS STILL A BUG, and confirmed by another user independently.
in fact, it means i cant use or rely upon identify without passing the verbose flag in.
in fact, it means i cant use or rely upon identify without passing the verbose flag in.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: identify fails silently on filenames with %d
If it works with -verbose and with my own custom version, then it should work with just identify. So I would agree that there is an apparent bug.
Perhaps you should repost to the Bugs forum.
Perhaps you should repost to the Bugs forum.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: identify fails silently on filenames with %d
This also works
convert 1%d.jpg info:
convert 1%d.jpg info:
Re: identify fails silently on filenames with %d
aaaand you just saved me from writing a wrapper to simulate the output from -verbose. thanks again!fmw42 wrote:This also works
convert 1%d.jpg info:
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: identify fails silently on filenames with %d
I would still suggest you repost to the bugs forum.
Re: identify fails silently on filenames with %d
crap, this isnt the bug forum. thanks, didnt realize because of the redirect for signing up to the forums.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: identify fails silently on filenames with %d
No % is not special in shell. never said it was.teleshoes wrote:Yes, i tried quoting the files, but you realize, thats handled by the SHELL, not by imagemagick; imagemagick receives the argument as the SAME STRING whether its quoted or not. {% is not special in bash.}
%d (and only %d, with optional numbers between the % and the d, such as %03d ) is special in Image reading to real numbered files. Actually I have not documented it very well in Image file reading either. But it is mentioned in the first read-modifier, section
http://www.imagemagick.org/Usage/files/#read_mods
So "file_%d.png[0-9]" will first try to read "file_0.png" then "file_1.png", and so on until it does not find a file.You can also get IM to read images based on a list of numbers. For example..will read in the files "image_005.png", "image_006.png", and "image_007.png". With this method you can not use a negative index.Code: Select all
convert 'image_%03d.png[5-7]' ...
It is a IM 'feature' but for your case it is a bug. It probably should ignore %d if no [...] component has been provided.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: identify fails silently on filenames with %d
i was referring to the earlier poster who suggested i quote it.anthony wrote:No % is not special in shell. never said it was.
this is not a case of a poorly documented feature with a distinct workaround, but behaviour that is explicitly different than the stated behaviours.anthony wrote:It is a IM 'feature' but for your case it is a bug. It probably should ignore %d if no [...] component has been provided.
in fact, the bug almost certainly isnt in the filename reading. it seems to be in the output, since the -verbose flag makes it work correctly.
{also, this is an example of a TERRIBLE feature. this is easily accomplished with a wrapper. the wrapper could be a separate tool, with explicit semantics: e.g.: identify -verbose `expand a%d.png 1 2 5 3 15 51`}