IM can't handle %% in paths
IM can't handle %% in paths
I have a problem with folders that contains %% and that I use [0] in the conversion. I see in the path from the error message that one % is "lost". Can some help me please?
### Test with folder that ends with %% and using[0], fails.
# convert ./karsten\ 93%%/Kalle.png[0] -profile /usr/local/axpa/webimage/iccs/sRGB.icc -geometry "1000x1000>" -depth 8 /tmp/tmp_sam.tif
convert: unable to open image './karsten 93%/Kalle.png': No such file or directory @ error/blob.c/OpenBlob/3375.
convert: no images defined `/tmp/tmp_sam.tif' @ error/convert.c/ConvertImageCommand/3275.
# identify /tmp/tmp_sam.tif
identify: unable to open image '/tmp/tmp_sam.tif': No such file or directory @ error/blob.c/OpenBlob/3375.
### Test with folder that ends with %% and without [0], works.
# convert ./karsten\ 93%%/Kalle.png -profile /usr/local/axpa/webimage/iccs/sRGB.icc -geometry "1000x1000>" -depth 8 /tmp/tmp_sam.tif
convert: delegate library support not built-in './karsten 93%%/Kalle.png' (LCMS) @ warning/profile.c/ProfileImage/836.
# identify /tmp/tmp_sam.tif
/tmp/tmp_sam.tif TIFF 544x687 544x687+0+0 8-bit sRGB 46952B 0.000u 0:00.009
# identify -version
Version: ImageMagick 7.0.7-26 Q16 x86_64 2018-03-15 http://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP
Delegates (built-in): cairo fontconfig freetype jng jpeg lzma png rsvg tiff x xml zlib
I'm running this on CentOS 7
Thanks
Åke
### Test with folder that ends with %% and using[0], fails.
# convert ./karsten\ 93%%/Kalle.png[0] -profile /usr/local/axpa/webimage/iccs/sRGB.icc -geometry "1000x1000>" -depth 8 /tmp/tmp_sam.tif
convert: unable to open image './karsten 93%/Kalle.png': No such file or directory @ error/blob.c/OpenBlob/3375.
convert: no images defined `/tmp/tmp_sam.tif' @ error/convert.c/ConvertImageCommand/3275.
# identify /tmp/tmp_sam.tif
identify: unable to open image '/tmp/tmp_sam.tif': No such file or directory @ error/blob.c/OpenBlob/3375.
### Test with folder that ends with %% and without [0], works.
# convert ./karsten\ 93%%/Kalle.png -profile /usr/local/axpa/webimage/iccs/sRGB.icc -geometry "1000x1000>" -depth 8 /tmp/tmp_sam.tif
convert: delegate library support not built-in './karsten 93%%/Kalle.png' (LCMS) @ warning/profile.c/ProfileImage/836.
# identify /tmp/tmp_sam.tif
/tmp/tmp_sam.tif TIFF 544x687 544x687+0+0 8-bit sRGB 46952B 0.000u 0:00.009
# identify -version
Version: ImageMagick 7.0.7-26 Q16 x86_64 2018-03-15 http://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP
Delegates (built-in): cairo fontconfig freetype jng jpeg lzma png rsvg tiff x xml zlib
I'm running this on CentOS 7
Thanks
Åke
Re: IM can't handle %% in paths
Why on earth would you want %% in a folder name?
Try putting you full image path in ""
Version 7 uses magick now over convert
Try putting you full image path in ""
Version 7 uses magick now over convert
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: IM can't handle %% in paths
So, if "%%" is converted to "%", and you need "%%", then you should type "%%%%".akes wrote:I see in the path from the error message that one % is "lost". Can some help me please?
snibgo's IM pages: im.snibgo.com
Re: IM can't handle %% in paths
If you look at the OP's input file path ./karsten\ 93%%/Kalle.png[0] it contains %% along with a white space and both \ and /So, if "%%" is converted to "%", and you need "%%", then you should type "%%%%".
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: IM can't handle %% in paths
Yes, the "/" is a directory delimiter in bash, and "\ " is a literal space within the directory name. I expect this command will work:
Personally, I don't allow special characters like % or spaces in filenames (which include directories). They are more trouble than they are worth.
Code: Select all
convert ./karsten\ 93%%%%/Kalle.png[0] -profile /usr/local/axpa/webimage/iccs/sRGB.icc -geometry "1000x1000>" -depth 8 /tmp/tmp_sam.tif
snibgo's IM pages: im.snibgo.com
Re: IM can't handle %% in paths
To stop 100+ users from using unwanted characters in file and folder names is a Sisyphean task. I think its something internal in IM since it only happens when I have %% in the path and [0] specified. Changing path in command from %% to %%%% works, but would require a change in the code that generates the IM commands.
Re: IM can't handle %% in paths
Even without [0], this command failed also:
With -debug TRACE it disappears around here:
Code: Select all
$ mkdir tmp%%
$ magick logo: 'tmp%%/logo.tif'
magick.exe: unable to open image 'tmp%/logo.tif': No such file or directory @ error/blob.c/OpenBlob/3109.
Code: Select all
...
2018-03-22T18:51:45+09:00 0:00.348 0.125u 7.0.6 Trace magick.exe[11600]: ../ImageMagick-7.0.6-7/MagickCore/option.c/DestroyImageOptions/2004/Trace
tmp%%/logo.tif
2018-03-22T18:51:45+09:00 0:00.348 0.125u 7.0.6 Trace magick.exe[11600]: ../ImageMagick-7.0.6-7/MagickCore/image.c/DestroyImageInfo/1253/Trace
2018-03-22T18:51:45+09:00 0:00.348 0.125u 7.0.6 Trace magick.exe[11600]: ../ImageMagick-7.0.6-7/MagickCore/option.c/DestroyImageOptions/2004/Trace
2018-03-22T18:51:45+09:00 0:00.348 0.125u 7.0.6 Trace magick.exe[11600]: ../ImageMagick-7.0.6-7/MagickCore/property.c/InterpretImageProperties/3350/Trace
tmp%/logo.tif
...
Last edited by 246246 on 2018-03-22T03:55:45-07:00, edited 1 time in total.
Re: IM can't handle %% in paths
So what you are saying is that you want Imagemagick to be rewritten just to help you?
I suggest in your code you copy the file to a location without any % or other problem characters and rename it to make sure there are none in the name.
Run the Imagemagick code on the image and save it back to the temporary location.
Copy/move it back to the new/original location renaming it with the problem characters
Or put your foot down and tell the users not to use anything other than alphanumeric characters and underscores.
I suggest in your code you copy the file to a location without any % or other problem characters and rename it to make sure there are none in the name.
Run the Imagemagick code on the image and save it back to the temporary location.
Copy/move it back to the new/original location renaming it with the problem characters
Or put your foot down and tell the users not to use anything other than alphanumeric characters and underscores.
Re: IM can't handle %% in paths
No, but I think it's a bug. Since I do not have the capabilities to check if it's so, I hope someone with the right knowledge will.
And since some of the images are 300MB+ I do not want to copy them before running the IM command.
Re: IM can't handle %% in paths
There was a similar post a while ago and nothing was changed and it was not treated as a bug: viewtopic.php?f=1&t=33537
As I said I think you should just stop people from using any character they want. I can not believe they can not name a folder or a file without resorting to symbols. What is to stop somebody creating a filename that when it is loaded into Imagemagick it compromises or crashes your server?
As I said I think you should just stop people from using any character they want. I can not believe they can not name a folder or a file without resorting to symbols. What is to stop somebody creating a filename that when it is loaded into Imagemagick it compromises or crashes your server?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: IM can't handle %% in paths
Sanitize your file and folder names in your OS before using in Imagemagick.
Did you try Bonzo's suggestion of enclosing the full path including the file and [0] inside double quotes?
Did you try Bonzo's suggestion of enclosing the full path including the file and [0] inside double quotes?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: IM can't handle %% in paths
The difficulty is that IM treats some characters in output filenames as special. For example "output_%[filename:mysize].tif" will substitute %[...] with something else.
IM doesn't (sadly) have an option for "don't treat any characters as special in output filenames". Instead, it uses an escape mechanism -- if you want "%" you need to put "%%", etc.
(In the same say, the C-language "printf(msg)" will always treat "%" in msg as special.)
It certainly isn't a bug: "%" is a special character to IM. I'd like an option for "don't treat any characters as special in output filenames". But I doubt it will be implemented.
If this is a common problem, symbolic links may be the solution.
IM doesn't (sadly) have an option for "don't treat any characters as special in output filenames". Instead, it uses an escape mechanism -- if you want "%" you need to put "%%", etc.
(In the same say, the C-language "printf(msg)" will always treat "%" in msg as special.)
It certainly isn't a bug: "%" is a special character to IM. I'd like an option for "don't treat any characters as special in output filenames". But I doubt it will be implemented.
If this is a common problem, symbolic links may be the solution.
snibgo's IM pages: im.snibgo.com
Re: IM can't handle %% in paths
Thank you for reminding me. I had thought the result in my simple testcase is an obvious bug.
Last edited by 246246 on 2018-07-11T05:53:39-07:00, edited 1 time in total.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: IM can't handle %% in paths
Another example:
IM interprets "%d", so the output is named "r0.png".
The "%" is escaped by a "%", so it is de-escaped to "%", and the output is named "r%d.png".
"%" isn't followed by anything magical, so the output is named "r%.png".
The "%" is escaped by a "%", so this output is also named "r%.png".
The first two are de-escaped to a single "%", and the final "%" isn't followed by anything magical, so the output is named "r%%.png".
And so on.
Code: Select all
convert rose: r%d.png
Code: Select all
convert rose: r%%d.png
Code: Select all
convert rose: r%.png
Code: Select all
convert rose: r%%.png
Code: Select all
convert rose: r%%%.png
And so on.
snibgo's IM pages: im.snibgo.com