spaces and annotations in filenames
spaces and annotations in filenames
I searched on Google without finding the answer to this question : how to use annotations in special filenames ?
ex: identify -format '%w %h' 'file name with spaces : and others caracters (1).jpg[0]'
systematically, I get in error "No such file or directory @ error/blob.c/OpenBlob/3146."
the only solution I found (but I do not like) :
cat 'file name with spaces : and others caracters (1).jpg' | identify -format '%w %h' -[0]
thank you very much ! (sorry for my English)
ex: identify -format '%w %h' 'file name with spaces : and others caracters (1).jpg[0]'
systematically, I get in error "No such file or directory @ error/blob.c/OpenBlob/3146."
the only solution I found (but I do not like) :
cat 'file name with spaces : and others caracters (1).jpg' | identify -format '%w %h' -[0]
thank you very much ! (sorry for my English)
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: spaces and annotations in filenames
You should say what version of IM you are using. Also say what shell you are using (eg bash, Windows CMD, etc) as they all behave differently. Some filesystems won't allow colons (":") in filenames.
Do you have a file with that name?
Do you have a file with that name?
snibgo's IM pages: im.snibgo.com
Re: spaces and annotations in filenames
Hello,
thank you for your reply. I use Bash with ImageMagick 7.0.7-11
You can reproduce the error with any file and even without the ":" character. I do not know if it's a bash bug or an ImageMagick bug. Use of a name with space and quotation marks work well IF there is no annotation "[0]". If there is "[0]", ImageMagick will scan the name and the error will appear.
identify -format '%w %h' 'file name with spaces.jpg'
No problem
identify -format '%w %h' 'file name with spaces.jpg'[0]
identify -format '%w %h' 'file name with spaces.jpg[0]'
Problem
thank you for your reply. I use Bash with ImageMagick 7.0.7-11
You can reproduce the error with any file and even without the ":" character. I do not know if it's a bash bug or an ImageMagick bug. Use of a name with space and quotation marks work well IF there is no annotation "[0]". If there is "[0]", ImageMagick will scan the name and the error will appear.
identify -format '%w %h' 'file name with spaces.jpg'
No problem
identify -format '%w %h' 'file name with spaces.jpg'[0]
identify -format '%w %h' 'file name with spaces.jpg[0]'
Problem
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: spaces and annotations in filenames
With v7, I think you should use "magick identify", not just "identify".
Strange. Those work fine for me, IM v7.0.3-5 (and v6.9.5-3) on Cygwin bash on Windows 8.1.
Strange. Those work fine for me, IM v7.0.3-5 (and v6.9.5-3) on Cygwin bash on Windows 8.1.
Code: Select all
$ magick identify -format '%w %h' 'file name.jpg'[0]
70 46
Alan@Fiona /cygdrive/f/web/im
$ magick identify -format '%w %h' 'file name.jpg[0]'
70 46
snibgo's IM pages: im.snibgo.com
Re: spaces and annotations in filenames
you are right, after verification the problem is the character ":"
sorry for my test error.
Code: Select all
$ identify -format '%w %h' 'file name : test2.jpg'[0]
identify: unable to open image 'file name : test2.jpg[0]': No such file or directory @ error/blob.c/OpenBlob/3146.
Last edited by nagame on 2018-02-19T13:21:32-07:00, edited 1 time in total.
Re: spaces and annotations in filenames
the ":" character is not allowed in Windows file names but allowed in Unix systems like...
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: spaces and annotations in filenames
There is no point in accessing layer [0] of a jpg file, since JPG does not allow layers. However, it should not hurt if you use the same code for gif or tiff or PDF which allow layers/pages/frames
Re: spaces and annotations in filenames
Okay. But that does not answer my question about the bug.
I just did a new test with a PDF :
I just did a new test with a PDF :
Code: Select all
identify -format '%w %h' 'file name : test2.PDF'[0]
identify: unable to open image 'file name : test2.PDF[0]': No such file or directory @ error/blob.c/OpenBlob/3146.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: spaces and annotations in filenames
I do not understand
identify -format '%w %h' 'file name : test2.PDF'[0]
Is filename : test2.pdf the name of your file including the spaces and colon?
Some OS do not allow colons in filenames.
Try using double quotes.
identify -format '%w %h' 'file name : test2.PDF'[0]
Is filename : test2.pdf the name of your file including the spaces and colon?
Some OS do not allow colons in filenames.
Try using double quotes.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: spaces and annotations in filenames
The real problem is that IM interprets characters before the colon as a format type, as in "PNG:abc.png", even if those characters aren't a format type.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: spaces and annotations in filenames
This works fine for me on IM 6.9.9.35 Q16 Mac OSX Sierra using double quotes.
My unix does not allow : in filenames.
Code: Select all
identify -format "%wx%h\n" "lena copy.png[0]"
Re: spaces and annotations in filenames
Thank you for your answers.
snibgo : no, because the colon alone works well (without [0]) => OK
If we add [0], it does not work anymore => NOK
The bug is the use of colon AND [0] in file names
@fmw42 : Yes but Linux accepts colon in file names :-/ I tried with double quotes, the bug is still true :
The only solution I found
snibgo : no, because the colon alone works well (without [0])
Code: Select all
identify -format '%w %h' 'filename:.PDF'
600 450
If we add [0], it does not work anymore
Code: Select all
identify -format '%w %h' 'filename:.PDF'[0]
identify: unable to open image 'filename:.PDF[0]': No such file or directory @ error/blob.c/OpenBlob/3146.
The bug is the use of colon AND [0] in file names
@fmw42 : Yes but Linux accepts colon in file names :-/ I tried with double quotes, the bug is still true :
Code: Select all
identify -format '%w %h' "filename:.PDF[0]"
identify: unable to open image 'filename:.PDF[0]': No such file or directory @ error/blob.c/OpenBlob/3146.
Code: Select all
cat 'filename:.PDF' | identify -format '%w %h' -[0]
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: spaces and annotations in filenames
On my Mac, if I try to put a colon in a filename, the Mac will object. It says "Try using a name with fewer characters, or with no punctuation marks"
Re: spaces and annotations in filenames
I can not see why the OP is adamant on using such bad file names. If the : does not work do not use it; the [0] is to indicate layers or items in an array.
What problems are going to crop up when trying to use the filenames in other software?
What happens if the filename has a : and it needs to be opened in a Windows or mac environment?
How can .pdf[0] be a valid file extension?
I would just say you can not use : or [0] at the end of a filename and call it a day.
What problems are going to crop up when trying to use the filenames in other software?
What happens if the filename has a : and it needs to be opened in a Windows or mac environment?
How can .pdf[0] be a valid file extension?
I would just say you can not use : or [0] at the end of a filename and call it a day.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: spaces and annotations in filenames
The page id [0], should be fine. I do not see that as a problem. I showed above that by removing the colon and still having spaces and [0] at the end worked fine on my Mac (unix) system. You just have to enclose the whole filename and [0] in double quotes as I showed above.