Filelist (@list.txt) quote escape

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
q3cpma
Posts: 5
Joined: 2015-08-26T13:45:40-07:00
Authentication code: 1151

Filelist (@list.txt) quote escape

Post by q3cpma »

Hello,
I have some trouble figuring the escape type needed in the following case:

Code: Select all

$ ls -1 --quoting-style=literal test*
test  "'.png
test.png
$ cat list.txt
'test  "'\''.png'
test.png
$ montage @list.txt out.png
montage: unable to open image `test  "': No such file or directory @ error/blob.c/OpenBlob/2705.
montage: no decode delegate for this image format `' @ error/constitute.c/ReadImage/504.
I've tried everything, (backlash escape, backlash + quotes) but I can't get it to work.

Using imagemagick 6.9.6 on Gentoo

Code: Select all

$ convert -version
Version: ImageMagick 6.9.6-6 Q16 x86_64 2016-12-03 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo fftw fontconfig freetype jng jp2 jpeg ltdl png rsvg tiff webp x zlib
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Filelist (@list.txt) quote escape

Post by snibgo »

Your filename contains space, and a single-quote, and a double quote. It needs to be quoted, because of the space. But neither double nor single quotes can be used.

The @-file is not interpreted by the shell, so shell escapes won't help. I don't think IM has an escape mechanism.

A workaround is to rename files so they don't contain special characters.
snibgo's IM pages: im.snibgo.com
q3cpma
Posts: 5
Joined: 2015-08-26T13:45:40-07:00
Authentication code: 1151

Re: Filelist (@list.txt) quote escape

Post by q3cpma »

So this is a bug?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Filelist (@list.txt) quote escape

Post by anthony »

Technically under unix filenames can even contain newline and return charactors!

The ONLY characters a filename can not have is slash '/' and null (character code 0). which is why find has a -print0 and xargs has a -0 form.

For ImageMagick. I am not certian what the limitations or even what the delimitors for a file list is. It may be returns or just whitespace, but judging from the error report it looks like it objected to the single quote (not the double).

Best solution around the 'bug' may be a temporary renaming method. as snibgo pointed out. That is what I would do because I would hate polluting the disk space with such horrible and awkward filenames anyway.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Filelist (@list.txt) quote escape

Post by snibgo »

IM objects to the space because, in that context, the delimiter is whitespace. Remove the space and it works fine.

In that context, a quote is needed to capture the space. The quote can be either type. But the filename already contains both types. So whichever type is used, the string terminates early.

The robust solution is probably (I'm not sure) to use the tokenizer in token.c instead of the simplistic code that is currently used.

Personally, I use clean filenames.
snibgo's IM pages: im.snibgo.com
Post Reply