convert fails when using special filenames
convert fails when using special filenames
Hello everyone,
during the automatic generation of differently-sized pictures i noticed the following:
I left out all options to narrow down the problem, normally the image would have been resized:
convert i1t_T1.tga i1t_T1[8x8].tga (works as expected, creates i1t_T1[8x8].tga)
convert i1t_T1.tga i1t_T1[hello].tga (works as expected, creates i1t_T1[hello].tga)
convert i1t_T1.tga i1t_T1[1024x1024].tga (nothing gets created, no error message)
convert i1t_T1.tga i1t_T1\[1024x1024\].tga (nothing gets created, no error message)
convert i1t_T1.tga i1t_T1[665x665].tga (nothing gets created, no error message)
convert i1t_T1.tga i1t_T1[666x666].tga (works)
This leaves me utterly confused. Any way i try to quote or escape, convert just quits and does not create an image.
I assume this is not related to the image itself, as it does work with some output filenames and no other operations are applied.
However, when i use another, similiarily named image (like i1t_T3.tga) everything works fine.
Please let me know if I should provide example images.
ImageMagick 6.4.0 07/27/08 Q16 on Fedora 10 x64, the same on OSX 10.5, 6.5.5-0 via macports.
All the best,
Johann Woelper
*** edit:
should have thought of that before, but -verbose gives additional insight:
convert -verbose i1t_T1.tga i1t_T1\[666x666\].tga
i1t_T1.tga TGA 1024x1024 1024x1024+0+0 DirectClass 8-bit 2.72476mb
i1t_T1.tga=>i1t_T1[666x666].tga TGA 1024x1024 1024x1024+0+0 DirectClass 8-bit 3.00002mb
(all ok)
convert -verbose i1t_T1.tga i1t_T1\[665x665\].tga
i1t_T1.tga TGA 1024x1024 1024x1024+0+0 DirectClass 8-bit 2.72476mb
i1t_T1.tga=>i1t_T15.tga TGA 1024x1024 1024x1024+0+0 DirectClass 8-bit 3.00002mb 0.020u 0:02
So it actually resolves '\[665x665\]' to '15', and jolly overwrites my i1t_T15.tga, which, by chance, i had in the same folder...
Is this expected behaviour?
during the automatic generation of differently-sized pictures i noticed the following:
I left out all options to narrow down the problem, normally the image would have been resized:
convert i1t_T1.tga i1t_T1[8x8].tga (works as expected, creates i1t_T1[8x8].tga)
convert i1t_T1.tga i1t_T1[hello].tga (works as expected, creates i1t_T1[hello].tga)
convert i1t_T1.tga i1t_T1[1024x1024].tga (nothing gets created, no error message)
convert i1t_T1.tga i1t_T1\[1024x1024\].tga (nothing gets created, no error message)
convert i1t_T1.tga i1t_T1[665x665].tga (nothing gets created, no error message)
convert i1t_T1.tga i1t_T1[666x666].tga (works)
This leaves me utterly confused. Any way i try to quote or escape, convert just quits and does not create an image.
I assume this is not related to the image itself, as it does work with some output filenames and no other operations are applied.
However, when i use another, similiarily named image (like i1t_T3.tga) everything works fine.
Please let me know if I should provide example images.
ImageMagick 6.4.0 07/27/08 Q16 on Fedora 10 x64, the same on OSX 10.5, 6.5.5-0 via macports.
All the best,
Johann Woelper
*** edit:
should have thought of that before, but -verbose gives additional insight:
convert -verbose i1t_T1.tga i1t_T1\[666x666\].tga
i1t_T1.tga TGA 1024x1024 1024x1024+0+0 DirectClass 8-bit 2.72476mb
i1t_T1.tga=>i1t_T1[666x666].tga TGA 1024x1024 1024x1024+0+0 DirectClass 8-bit 3.00002mb
(all ok)
convert -verbose i1t_T1.tga i1t_T1\[665x665\].tga
i1t_T1.tga TGA 1024x1024 1024x1024+0+0 DirectClass 8-bit 2.72476mb
i1t_T1.tga=>i1t_T15.tga TGA 1024x1024 1024x1024+0+0 DirectClass 8-bit 3.00002mb 0.020u 0:02
So it actually resolves '\[665x665\]' to '15', and jolly overwrites my i1t_T15.tga, which, by chance, i had in the same folder...
Is this expected behaviour?
Last edited by jwoelper on 2009-08-26T11:04:02-07:00, edited 1 time in total.
Re: convert fails when using special filenames
This works for us:
- convert i1t_T1.tga 'i1t_T1[1024x1024].tga'
Re: convert fails when using special filenames
Hi!magick wrote:This works for us:
We're using ImageMagick 6.5.5-2.
- convert i1t_T1.tga 'i1t_T1[1024x1024].tga'
Thanks for the quick reply. I guess this works because you are lacking the files i have (sorry for not letting you know: my directory contains a large number of sequentially numbered files, like i1t_T1.tga, i1t_T2.tga, i1t_T3.tga...)
so, if i run the command you suggested, i get:
convert i1t_T1.tga 'i1t_T1[1024x1024].tga'
i1t_T1.tga TGA 1024x1024 1024x1024+0+0 DirectClass 8-bit 2.72476mb
i1t_T10.tga TGA 1024x1024 1024x1024+0+0 DirectClass 8-bit 3.00002mb
i1t_T11.tga TGA 16x16 16x16+0+0 DirectClass 8-bit 786b
i1t_T12.tga[0] TGA 128x128 128x128+0+0 DirectClass 8-bit 112.035kb
i1t_T12.tga[1] TGA 128x128 128x128+0+0 DirectClass 8-bit 112.035kb
i1t_T1.tga=>i1t_T14.tga[0] TGA 1024x1024 1024x1024+0+0 DirectClass 8-bit 6.11019mb
i read the man page, and i assumed the brackets should only be recognized if they are behind the extention, like 'convert catalogue.pdf[10] page.tif'?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert fails when using special filenames
brackets refer to a subsection on the input image or to an image frame (sequence), but appear AFTER the suffix
see Selecting an Image Region on http://www.imagemagick.org/script/comma ... .php#input
So I suspect you may have trouble with filenames that have [ ... ] in the primary part of the filename prior to the suffix.
Don't know if putting quotes around the filename will help.
see Selecting an Image Region on http://www.imagemagick.org/script/comma ... .php#input
So I suspect you may have trouble with filenames that have [ ... ] in the primary part of the filename prior to the suffix.
Don't know if putting quotes around the filename will help.
Re: convert fails when using special filenames
I see... so there would be no way handling images that have brackets in the filename? Quoting does not help... is there any other method of escaping the brackets?fmw42 wrote:brackets refer to a subsection on the input image or to an image frame (sequence), but appear AFTER the suffix
see Selecting an Image Region on http://www.imagemagick.org/script/comma ... .php#input
So I suspect you may have trouble with filenames that have [ ... ] in the primary part of the filename prior to the suffix.
Don't know if putting quotes around the filename will help.
All the best,
Johann
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert fails when using special filenames
if on unix, you could try
image\[8x8\].gif
but if quotes does not work, i doubt this will work. But I am no expert on these things.
image\[8x8\].gif
but if quotes does not work, i doubt this will work. But I am no expert on these things.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: convert fails when using special filenames
the [..] is a special syntax to IM on input only if it is AFTER the suffix
However [..] is special to most command line shells, such as BASH.
it means any ONE charcater in the backaets appear here.
That is xyzzy[192].txt
will look for the files xyzzy1.txt xyzzy2.txt xyzzy9.txt (order made alphabetical)
to prevent the shell treating the [..] as special you MUST quote or backslash escape the brackets. NOTE the BASH shell also treat (..) and {..} as special too!
However [..] is special to most command line shells, such as BASH.
it means any ONE charcater in the backaets appear here.
That is xyzzy[192].txt
will look for the files xyzzy1.txt xyzzy2.txt xyzzy9.txt (order made alphabetical)
to prevent the shell treating the [..] as special you MUST quote or backslash escape the brackets. NOTE the BASH shell also treat (..) and {..} as special too!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert fails when using special filenames
Anthony,
so for my own edification, do you quote the whole filename or just the brackets
'filename[8x8].jpg'
or
filename'[8x8]'.jpg
or something else
so for my own edification, do you quote the whole filename or just the brackets
'filename[8x8].jpg'
or
filename'[8x8]'.jpg
or something else
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: convert fails when using special filenames
I generally quote the whole filename if it is needed. But for IM input modifications I usually only quote the modification.
It really only matters if you have special characters in the filename. OR you are using a variable to hold the filename.
Code: Select all
convert 'input_[8x8]_image.jpg' ...
convert input_image.jpg'[100x100+20+20]' ...
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: convert fails when using special filenames
anthony wrote:I generally quote the whole filename if it is needed. But for IM input modifications I usually only quote the modification.
It really only matters if you have special characters in the filename. OR you are using a variable to hold the filename.Code: Select all
convert 'input_[8x8]_image.jpg' ... convert input_image.jpg'[100x100+20+20]' ...
Hi! Thanks for the example. However, this still does not work.
As I wrote above, the command
Code: Select all
convert -verbose i1t_T1.tga 'i1t_T1[1024x1024].tga'
i1t_T1.tga TGA 1024x1024 1024x1024+0+0 8-bit DirectClass 4mb
i1t_T10.tga TGA 1024x1024 1024x1024+0+0 8-bit DirectClass 4mb
i1t_T11.tga TGA 16x16 16x16+0+0 8-bit DirectClass 1.02kb
i1t_T12.tga[0] TGA 128x128 128x128+0+0 8-bit DirectClass 128kb
i1t_T12.tga[1] TGA 128x128 128x128+0+0 8-bit DirectClass 128kb
and, as you suggested,
Code: Select all
convert -verbose i1t_T1.tga i1t_T1'[1024x1024]'.tga
i1t_T1.tga TGA 1024x1024 1024x1024+0+0 8-bit DirectClass 4mb
i1t_T10.tga TGA 1024x1024 1024x1024+0+0 8-bit DirectClass 4mb
i1t_T11.tga TGA 16x16 16x16+0+0 8-bit DirectClass 1.02kb
i1t_T12.tga[0] TGA 128x128 128x128+0+0 8-bit DirectClass 128kb
i1t_T12.tga[1] TGA 128x128 128x128+0+0 8-bit DirectClass 128kb
i1t_T1.tga=>i1t_T14.tga[0] TGA 1024x1024 1024x1024+0+0 8-bit DirectClass 8.125mb 0.130u 0:02
My folder contains a sequence of i1t_T(1-60).tga
regards,
Johann
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert fails when using special filenames
stupid question, but why are you putting such brackets on output filenames?
if you must do something like that, then could you not just use a hyphen or underscore as a separator?
convert -verbose i1t_T1.tga i1t_T1_1024x1024.tga
if you must do something like that, then could you not just use a hyphen or underscore as a separator?
convert -verbose i1t_T1.tga i1t_T1_1024x1024.tga
Re: convert fails when using special filenames
fmw42 wrote:stupid question, but why are you putting such brackets on output filenames?
if you must do something like that, then could you not just use a hyphen or underscore as a separator?
convert -verbose i1t_T1.tga i1t_T1_1024x1024.tga
Well you're so right. Unfortunately, some proprietary software forced these filenames upon us. Of course i could rename the files (and that is what I did) but I do not think the way Imagemagick handles the filename is expected. So, as I am trying to help improve this wonderful software, I thought I should post this. Or, at least, if somebody runs into a similiar problem, she or he could see that brackets in filenames cause some weird results.
All the best
Johann
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: convert fails when using special filenames
I would agree that the brackets should work as expected. If the shell is not getting in the way and the quoting does prevent that, then I can't see why IM doesn't output brackets!
On output filename the only thing IM is currently looking for (as far as I know) is
%d as a printf format something like %03d OR a %[filename:string] See...
http://www.imagemagick.org/Usage/files/#save_escapes
so perhaps the %[...] handling is being a little over zelious and doing [...] as well.
On output filename the only thing IM is currently looking for (as far as I know) is
%d as a printf format something like %03d OR a %[filename:string] See...
http://www.imagemagick.org/Usage/files/#save_escapes
so perhaps the %[...] handling is being a little over zelious and doing [...] as well.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/