File name containing ':' can't be escaped if frame used
File name containing ':' can't be escaped if frame used
Hi.
PerlMagick from IM 6.7.5-10 can't process first frame in file names with ':' inside because it always mistreat the first part before ':' as image format. I try to escape ':' with backslashes, but it does not help (I try with 1-4 backsklashes). I mean calls like that:
$imagename = "foo:bar.ext";
$image->Read("${imagename}\[0\]");
Error: Exception 420: no decode delegate for this image format `bar.ext' @ error/constitute.c/ReadImage/532
Single backslash works, only if no ...[0] part present, i.e. that works:
$imagename = "foo\:bar.ext";
$image->Read("${imagename}");
but that don't:
$imagename = "foo\:bar.ext";
$image->Read("${imagename}\[0\]");
Following workaround
$imagename = "GIF:foo\:bar.ext";
requires image format be known at the moment of reading, which is not always so.
Please fix this bug. I remember that some old IM versions does not have it.
PerlMagick from IM 6.7.5-10 can't process first frame in file names with ':' inside because it always mistreat the first part before ':' as image format. I try to escape ':' with backslashes, but it does not help (I try with 1-4 backsklashes). I mean calls like that:
$imagename = "foo:bar.ext";
$image->Read("${imagename}\[0\]");
Error: Exception 420: no decode delegate for this image format `bar.ext' @ error/constitute.c/ReadImage/532
Single backslash works, only if no ...[0] part present, i.e. that works:
$imagename = "foo\:bar.ext";
$image->Read("${imagename}");
but that don't:
$imagename = "foo\:bar.ext";
$image->Read("${imagename}\[0\]");
Following workaround
$imagename = "GIF:foo\:bar.ext";
requires image format be known at the moment of reading, which is not always so.
Please fix this bug. I remember that some old IM versions does not have it.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: File name containing ':' can't be escaped if frame used
Note that doing
done NOTHING in perl. You escaped the ':' in the double quotes which for perl just removes the backslash.
To pass teh bashslash to Imagemagick you need to escape the backshash itself!!!!
that is you need to use....
the alturnative is to use single quotes! But then you can insert variables into the string!
Know your perl!
I am thinking that a 'literal file name read' type setting should be added as this can be useful for both API's (like perl) and for command line. I have a note about something like that for the current Imv7 development but it is close to the bottom of the very long to-do list.
Code: Select all
$imagename = "foo\:bar.ext";
To pass teh bashslash to Imagemagick you need to escape the backshash itself!!!!
that is you need to use....
Code: Select all
$imagename = "foo\\:bar.ext";
Code: Select all
$imagename = 'foo\:bar.ext';
Know your perl!
I am thinking that a 'literal file name read' type setting should be added as this can be useful for both API's (like perl) and for command line. I have a note about something like that for the current Imv7 development but it is close to the bottom of the very long to-do list.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: File name containing ':' can't be escaped if frame used
I already mention that I try with 1-4 backslashes with the same result (and both types of quotes). Here is full script with the string you suggest as working:
BTW, another string you suggest "foo\\:bar.ext\[0\]" does not work too.
Adding literal flag will be good, but currently it is obvious parser regression: ":" can't be escaped when reading [frame]
Code: Select all
#!/usr/bin/perl -w
use Image::Magick;
my $imagename = 'foo\:bar.ext[0]';
my $image = Image::Magick->new;
my $status = $image->Read($imagename);
print "$status\n" if ($status);
Code: Select all
Exception 420: no decode delegate for this image format `bar.ext' @ error/constitute.c/ReadImage/532
Adding literal flag will be good, but currently it is obvious parser regression: ":" can't be escaped when reading [frame]
Re: File name containing ':' can't be escaped if frame used
The problem you reported should be fixed in ImageMagick 6.7.6-7. If you have further problems, let us know.
Re: File name containing ':' can't be escaped if frame used
I just test this examplemagick wrote:The problem you reported should be fixed in ImageMagick 6.7.6-7. If you have further problems, let us know.
Code: Select all
#!/usr/bin/perl -w
use Image::Magick;
my $imagename = 'foo\:bar.ext[0]';
my $image = Image::Magick->new;
my $status = $image->Read($imagename);
print "$status\n" if ($status);
Still get:
Code: Select all
Exception 420: no decode delegate for this image format `bar.ext' @ error/constitute.c/ReadImage/544
Re: File name containing ':' can't be escaped if frame used
This seems to work:
- -> convert logo: rose: gif:foo:bar.ext
-> display 'gif:foo:bar.ext[1]'
- convert logo: rose: foo:bar.gif
display 'implicit:foo:bar.gif[1]'
display ':foo:bar.gif[1]'
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: File name containing ':' can't be escaped if frame used
I have not seen the syntax "implicit::..." or even ":..." before.
Does implicit: also make the read modifier implicit?
Does implicit: also make the read modifier implicit?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: File name containing ':' can't be escaped if frame used
First one works because you directly specify pre-known format. But format of the file can be not known. Extension sometimes hides real format, f.e. some image hostings preserve .GIF on uploaded file but put JPEG format inside.
Second one in 6.7.6-9
gives error:
Third version
works, thanks. However this kind of escaping looks a little strange and not intuitive.
Update: implicit: (with one colon instead of two) works, thanx.
Second one in 6.7.6-9
Code: Select all
my $imagename = 'implicit::foo:bar.ext[0]';
Code: Select all
Exception 435: unable to open image `:foo:bar.ext': No such file or directory @ error/blob.c/OpenBlob/2617
Code: Select all
my $imagename = ':foo:bar.ext[0]';
Update: implicit: (with one colon instead of two) works, thanx.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: File name containing ':' can't be escaped if frame used
Thanks for the clarification.
However I know from looking at code, that an 'implicit:' prefix will not prevent IM expanding globs ('*' and '?'), at least in the Shell API (does not apply to other API's)
so if you have a filename called "implicit:abc.jpg"
and you request "implicit:*.jpg" (with quotes to prevent shell glob expansion)
IM may still expand that
For example
will still show the 'rose:' image from implicit:abc.jpg
This would currently happen in BOTH IMv6 (global glob expansion) and IMv7 (which restricts glob expansion to image reads only).
Summary....
At this time filenames may have the following expansions, (from my Shell API project list)
I hope to add a setting (sometime during beta development) to selectively enable/disable these expansions.
This would work better than the use of 'implicit:' which is itself an expansion.
However I know from looking at code, that an 'implicit:' prefix will not prevent IM expanding globs ('*' and '?'), at least in the Shell API (does not apply to other API's)
so if you have a filename called "implicit:abc.jpg"
and you request "implicit:*.jpg" (with quotes to prevent shell glob expansion)
IM may still expand that
For example
Code: Select all
convert rose: t.jpg
mv t.jpg implicit:abc.jpg
convert 'implicit:*.jpg' show:
This would currently happen in BOTH IMv6 (global glob expansion) and IMv7 (which restricts glob expansion to image reads only).
Summary....
At this time filenames may have the following expansions, (from my Shell API project list)
Code: Select all
filelist @filelist.txt
glob use of '~', '*', and '?'
coder CODER: prefix
read_mods [...] postfix (read only at this time)
escape %[filename:...] (write only at this time)
enumeration %d formatting (using -scenes for read (undocumented)
or a[#,#-#] read modifier, and -scene for write)
This would work better than the use of 'implicit:' which is itself an expansion.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/