Page 1 of 1

Using [n-N] syntax with period at start of filenames fails to open files

Posted: 2015-08-20T22:12:08-07:00
by HomerJohnston
Hi all, using 6.9.2-0 Q16 x64, 2015-08-15, prebuilt Windows binary.

I have any image files:

test_1.png
test_2.png
test_3.png
test_4.png

I execute:

Code: Select all

montage "test_[0-3].png" "output.tif"
This works.
---------------------------
Next I rename files to:

.test_1.png
.test_2.png
.test_3.png
.test_4.png

I execute:

Code: Select all

montage ".test_[0-3].png" "output.tif"
This causes the following error:
montage.exe: UnableToOpenBlob `.test_[0-3].png': No such file or directory @ error/blob.c/OpenBlob/2695.
montage.exe: UnableToOpenFile `.test_[0-3].png' @ error/png.c/ReadPNGImage/3913.
montage.exe: MissingAnImageFilename `output.tif' @ error/montage.c/MontageImageCommand/1790.
---------------------------
Next, I execute:

Code: Select all

montage ".test_1.png" ".test_2.png" ".test_3.png" ".test_4.png" "output.tif"
This works. I can use this solution for now, but may run into cases where I'll exceed the 8191 cmd prompt character limit :)

Note: it works if the period is located in the middle of the file name, just not the start.

Re: Using [n-N] syntax with period at start of filenames fails to open files

Posted: 2015-08-20T23:03:35-07:00
by fmw42
The brackets at http://www.imagemagick.org/Usage/montage/#tile are Unix. I am surprised they work on Window. As listed on that page:

"The strange "[1-5]" syntax is a UNIX shell shorthand, which is expanded into a list of filenames. The "montage" command itself does not see these characters, just the resulting list of files."

Perhaps in Windows syntax, the period at the start of filenames has a special meaning? I am not a Windows user, so I cannot test that properly. But in Unix, you cannot even name a file starting with a period, because a leading period has special meaning.

Does the following work?

Code: Select all

montage .test_*.png output.tif
or

Code: Select all

montage ".test_*.png" output.tif

Re: Using [n-N] syntax with period at start of filenames fails to open files

Posted: 2015-08-21T05:42:27-07:00
by snibgo
Removed. Please ignore.

Re: Using [n-N] syntax with period at start of filenames fails to open files

Posted: 2015-08-21T08:19:45-07:00
by 246246
Usually filename expansion is done by shell (or in Windows command processor), but ImageMagick itself expand filename after shell expansion for preparing the case TIFF:foo*.tiff, foo*.psd[0] etc.
The argument list shown by -debug Configure is the one after expansion by ImageMagick. So it is not Windows that expand test_[0-3].png in this case.

You can confirm PNG:.test_*.png failed to expand even in Unix.

And it seems it is intentionally - there is a comment of ExpandFilenames() in utility.c

Code: Select all

%  WARNING: filenames starting with '.' (hidden files in a UNIX file system)
%  will never be expanded.  Attempting to epand '.*' will produce no change.
I don't know why, however.

Re: Using [n-N] syntax with period at start of filenames fails to open files

Posted: 2015-08-21T08:36:35-07:00
by snibgo
246246 wrote:The argument list shown by -debug Configure is the one after expansion by ImageMagick.
I didn't know that. Thanks for the correction. Testing with other programs shows that Windows does not expand the [0-3] notation, so it must be by ImageMagick.