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

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
HomerJohnston
Posts: 4
Joined: 2014-12-16T23:48:53-07:00
Authentication code: 6789

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

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

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

Post by snibgo »

Removed. Please ignore.
snibgo's IM pages: im.snibgo.com
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

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

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

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

Post 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.
snibgo's IM pages: im.snibgo.com
Post Reply