read frame syntax doesn't work when filename contains ':'

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
oliverhenshaw
Posts: 5
Joined: 2011-08-02T15:04:48-07:00
Authentication code: 8675308

read frame syntax doesn't work when filename contains ':'

Post by oliverhenshaw »

convert has a problem when the input filename contains ':' - e.g in a timestamp - and I use [0] to specify the first image frame.

$ convert -resize 1024x600 -verbose test-18\:37.jpg small/test-18\:37.jpg
test-18:37.jpg JPEG 1944x2592 1944x2592+0+0 8-bit DirectClass 2.651MB 0.130u 0:00.139
test-18:37.jpg=>small/test-18:37.jpg JPEG 1944x2592=>450x600 450x600+0+0 8-bit DirectClass 147KB 0.500u 0:00.240
$ convert -resize 1024x600 -verbose test-18\:37.jpg[0] small/test-18\:37.jpg
convert: no decode delegate for this image format `37.jpg' @ error/constitute.c/ReadImage/532.
convert: missing an image filename `small/test-18:37.jpg' @ error/convert.c/ConvertImageCommand/2949.

whereas both versions work if the file is named "test.jpg".


This worked in fedora 13 and doesn't in fedora 15:

bash-4.1.7-1.fc13.x86_64 -> bash-4.2.10-4.fc15.x86_64
ImageMagick-6.5.8.10-7.fc13.x86_64 -> ImageMagick-6.6.5.10-19.fc15.x86_64
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: read frame syntax doesn't work when filename contains ':

Post by fmw42 »

try putting quotes around your filenames

convert -resize 1024x600 -verbose "test-18\:37.jpg" "small/test-18\:37.jpg"


better syntax would be:

convert "test-18\:37.jpg" -resize 1024x600 -verbose "small/test-18\:37.jpg"


see
http://www.imagemagick.org/Usage/basics/#why
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: read frame syntax doesn't work when filename contains ':

Post by anthony »

Note that using '\:' in a filename works because then IM is escaping its special meaning of ':'.

that same goes for meta-charcaters such as '?' and '*'.

Remember not only does the shell handle meta-characters (unless that argument is quoted) but IM also does its own form of meta-character handling in filenames.

For example

Code: Select all

  convert  *.jpg ....
is expanded by the shell BEFORE passing the filenames to IM, while

Code: Select all

  convert  '*.jpg' ....
passes just "*.jpg" whcih IM then expands into a internal list of filenames! (provided for Windows Dos support, and preventing command line limit overflows).

As such to actually get IM to read a file names literially named on disk as '*.jpg' you need to use any of the following forms...

Code: Select all

  convert  '\*.jpg' ....
 convert "\*.jpg" ....
 convert "\\*.jpg" ....
 convert \\\*.jpg ....
NOTE; the second line is NOT recommended as some shells (not bash) and some APIs (C programs, possibly PHP) may actually remove the single backslash, and pass '*.jpg' to IM which it will again expand!

On top of '?' and '*', IM also adds the meta-character handling of ':', '%' and '[...]' for read modifier handling. These however have a different meaning (codec specification, scene number inclusion, and read modifiers) to normal shell syntax of those meta-characters.

This is something I'll add to IM examples, File Handling Reading.
It would also probably solve problems that Window uses have with dos drive letters.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: read frame syntax doesn't work when filename contains ':

Post by anthony »

An alternative is to use a question mark...

Code: Select all

  convert "time_10?30.jpg" ...
However that may also match another file such as "time_10_30.jpg" as well!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
oliverhenshaw
Posts: 5
Joined: 2011-08-02T15:04:48-07:00
Authentication code: 8675308

Re: read frame syntax doesn't work when filename contains ':

Post by oliverhenshaw »

None of that seems to work, maybe I'm missing something. It's the combination of the colon and the '[0]' modifier at the end that causes problems.

I've played around a little but still can't work out what combination of quotes and escapes will make this work:

Code: Select all

$ convert -resize 1024x600 -verbose test-18\:37.jpg[0] small/test-18\:37.jpg
convert: no decode delegate for this image format `37.jpg' @ error/constitute.c/ReadImage/532.
convert: missing an image filename `small/test-18:37.jpg' @ error/convert.c/ConvertImageCommand/2949.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: read frame syntax doesn't work when filename contains ':

Post by fmw42 »

try

convert "test-18:37.jpg[0]" -resize 1024x600 -verbose "small/test-18:37.jpg"
oliverhenshaw
Posts: 5
Joined: 2011-08-02T15:04:48-07:00
Authentication code: 8675308

Re: read frame syntax doesn't work when filename contains ':

Post by oliverhenshaw »

fmw42 wrote:try

convert "test-18:37.jpg[0]" -resize 1024x600 -verbose "small/test-18:37.jpg"
Doesn't work.

I started testing old livecds to see when it stopped working

Code: Select all

      ImageMagick        Bash
GOOD  6.5.8.10-6.fc13    4.1.2-4.fc13
GOOD  6.5.8.10-6.fc13    4.1.7-1.fc13
GOOD  6.5.8.10-7.fc13    4.1.7-1.fc13
BAD   6.6.4.1-14.fc14    4.1.7-3.fc14
Looks more likely to be a change in ImageMagick than a change in bash?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: read frame syntax doesn't work when filename contains ':

Post by magick »

We can reproduce the problem you posted and will have a patch to fix it within a day or two. Thanks.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: read frame syntax doesn't work when filename contains ':

Post by anthony »

hmmmm

Code: Select all

convert rose: t.jpg
mv t.jpg test-18:37.jpg
convert test-18:37.jpg info:
test-18:37.jpg JPEG 70x46 70x46+0+0 8-bit DirectClass 2.05KB 0.000u 0:00.010
seems to work fine

The use of '[0]' read modifier with JPEG is redundant as JPEG can only contain one image. however...

Code: Select all

convert test-18:37.jpg'[0]' info:convert test-18:37.jpg'[0]' info:
convert: no decode delegate for this image format `37.jpg' @ error/constitute.c/ReadImage/532.
convert: missing an image filename `info:' @ error/convert.c/ConvertImageCommand/3015.
failure.

Code: Select all

convert 'test-18\:37.jpg[0]' info:
convert: no decode delegate for this image format `37.jpg' @ error/constitute.c/ReadImage/532.
convert: missing an image filename `info:' @ error/convert.c/ConvertImageCommand/3015.
also failed.

Presumably filename parsing when a read modifier is present is at fault.

Code: Select all

convert 'test-18\:37.jpg[10x10+10+10]' info:
convert: no decode delegate for this image format `37.jpg' @ error/constitute.c/ReadImage/532.
convert: missing an image filename `info:' @ error/convert.c/ConvertImageCommand/3015.
Does not matter what type of read modifier either.

Downloading latest IMv6 SVN changes now.. Not fixed yet.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
oliverhenshaw
Posts: 5
Joined: 2011-08-02T15:04:48-07:00
Authentication code: 8675308

Re: read frame syntax doesn't work when filename contains ':

Post by oliverhenshaw »

anthony wrote:The use of '[0]' read modifier with JPEG is redundant as JPEG can only contain one image
Note for interest: this comes from digikam (really kipi-plugins) which is how I first noticed the problem.

It looks like the kipi-plugin batch resizer works by building a 'convert' command to run for every file being processed, like so. The '[0]' read modifier seems to have been added to prevent problems with files containing thumbnails - is doing this for all ImageMagick commands too broad a brush?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: read frame syntax doesn't work when filename contains ':

Post by magick »

Grab ImageMagick-6.7.1-2. We verified that the test-18:37.jpg[0] filename works fine with it.
oliverhenshaw
Posts: 5
Joined: 2011-08-02T15:04:48-07:00
Authentication code: 8675308

Re: read frame syntax doesn't work when filename contains ':

Post by oliverhenshaw »

The stars were finally right and I managed to test this, and the fix does indeed work. Tested both by backporting into a locally built rpm in Fedora 15 and by testing 6.7.1-9 in a F16 virtual machine.

Thank, belatedly.
hjr
Posts: 1
Joined: 2011-10-12T08:14:48-07:00
Authentication code: 8675308

Re: read frame syntax doesn't work when filename contains ':

Post by hjr »

Hello,

Recently we upgraded ImageMagick from

Code: Select all

Version: ImageMagick 6.6.7-10 2011-04-08 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
to

Code: Select all

Version: ImageMagick 6.7.3-0 2011-10-12 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
And this problem appeared again. Using [0] on any file yields

Code: Select all

convert: unable to open image `/path/filename.jpg[0]': No such file or directory @ error/blob.c/OpenBlob/2589.
Problem appears on FreeBSD 7.3-RELEASE-p2 (compiled from ports collection) and on Windows-64-static build.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: read frame syntax doesn't work when filename contains ':

Post by magick »

We can reproduce this problem and will have a patch in ImageMagick 6.7.3-1 Beta by sometime tomorrow. Thanks.
Post Reply