Page 1 of 1

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

Posted: 2011-08-02T15:32:20-07:00
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

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

Posted: 2011-08-02T16:26:12-07:00
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

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

Posted: 2011-08-02T19:08:37-07:00
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.

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

Posted: 2011-08-02T19:19:10-07:00
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!

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

Posted: 2011-08-03T02:26:06-07:00
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.

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

Posted: 2011-08-03T09:19:50-07:00
by fmw42
try

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

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

Posted: 2011-08-03T10:06:49-07:00
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?

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

Posted: 2011-08-03T10:26:18-07:00
by magick
We can reproduce the problem you posted and will have a patch to fix it within a day or two. Thanks.

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

Posted: 2011-08-03T21:03:12-07:00
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.

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

Posted: 2011-08-04T06:37:44-07:00
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?

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

Posted: 2011-08-04T07:09:20-07:00
by magick
Grab ImageMagick-6.7.1-2. We verified that the test-18:37.jpg[0] filename works fine with it.

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

Posted: 2011-09-18T12:59:55-07:00
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.

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

Posted: 2011-10-12T08:30:53-07:00
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.

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

Posted: 2011-10-12T12:25:44-07:00
by magick
We can reproduce this problem and will have a patch in ImageMagick 6.7.3-1 Beta by sometime tomorrow. Thanks.