spaces and annotations in filenames

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?".
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: spaces and annotations in filenames

Post by snibgo »

Ideally, IM would have a setting that meant: "Ignore special characters in filenames." But it doesn't, so including characters like ":[]" in filenames creates ambiguity, which is a bad idea. For example:

Code: Select all

TIFF:abc.tiff
Is this a file named "abc.tiff" with a "TIFF:" prefix, or is it a file named "TIFF:abc.tiff" with no prefix?

IM takes a dual approach, searching for both filenames.

The same problem occurs with square brackets:

Code: Select all

abc.tiff[0]
This might be a file named "abc.tiff" with an added suffix, or "abc.tiff[0]" with no suffix. (".tiff[0]" is a valid extension on Windows).

Again, IM will actually search for both.

But that is a total of four combinations, and IM won't search for all four. That's why a colon in the name, with square brackets not in the name, won't be found.

If a workflow accepts colons in filenames, then there might be two different files:

Code: Select all

abc.tiff
TIFF:abc.tiff
Suppose a convert command refers to "TIFF:abc.tiff". Which of those files should be used? Doubtless we could figure out which one IM will use, but it clearly causes confusion.

In my view, the best way to avoid the confusion is to have a workflow that prohibits any of ":[]" in filenames.
snibgo's IM pages: im.snibgo.com
nagame
Posts: 10
Joined: 2018-02-18T16:43:03-07:00
Authentication code: 1152

Re: spaces and annotations in filenames

Post by nagame »

@Bonzo, @fmw42 : I understand that you are surprised to see colon in the file names. I also agree.
In my case, my company offers a web service for my clients (CMS). I do not ask my clients why filenames with colon. I see the errors in the logs of my server and I look for a solution. I found a first solution with the tool cat, a second is to remove the colon character of the file names. But from my point of view, it's still a bug in ImageMagick.
nagame
Posts: 10
Joined: 2018-02-18T16:43:03-07:00
Authentication code: 1152

Re: spaces and annotations in filenames

Post by nagame »

@snibgo : thanks for that precise answer. I understand now. I am going to modify our workflow to ban the characters ": [ ]"
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: spaces and annotations in filenames

Post by snibgo »

If you allow uploads from anyone, there are also security considerations. For example, don't allow quote characters.
snibgo's IM pages: im.snibgo.com
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: spaces and annotations in filenames

Post by Bonzo »

@nagame it took me a while when I was starting out to realise spaces in filenames could be a pain as well!
Post Reply