Page 1 of 1

Unable to pass variable filepath

Posted: 2016-04-22T10:19:20-07:00
by Mshepelev
I'm trying to pass a filepath from a variable as following

Code: Select all

convert -quality 100 -density 500 $FILE[$PAGES] page.jpg
and for some reason if a filename contains spaces im gettings following output:

Code: Select all

convert.im6: unable to open image `/home/mshepelev/Test/NEW\': No such file or directory @ error/blob.c/OpenBlob/2638.
convert.im6: no decode delegate for this image format `/home/mshepelev/Test/NEW\' @ error/constitute.c/ReadImage/544.
convert.im6: unable to open image `Cutting\': No such file or directory @ error/blob.c/OpenBlob/2638.
convert.im6: no decode delegate for this image format `Cutting\' @ error/constitute.c/ReadImage/544.
convert.im6: unable to open image `Edge\': No such file or directory @ error/blob.c/OpenBlob/2638.
convert.im6: no decode delegate for this image format `Edge\' @ error/constitute.c/ReadImage/544.
convert.im6: unable to open image `Upper-Intermediate\': No such file or directory @ error/blob.c/OpenBlob/2638.
convert.im6: no decode delegate for this image format `Upper-Intermediate\' @ error/constitute.c/ReadImage/544.
convert.im6: unable to open image `TB.pdf': No such file or directory @ error/blob.c/OpenBlob/2638.
convert.im6: no decode delegate for this image format `TB.pdf' @ error/constitute.c/ReadImage/544.
convert.im6: no images defined `page.jpg' @ error/convert.c/ConvertImageCommand/3044.
whereas when following command works fine:

Code: Select all

convert /home/mshepelev/Test/NEW\ Cutting\ Edge\ Upper-Intermediate\ TB.pdf test.jpg
it seems like when passing a variable as input filename it is getting splitted by space sign ignoring escape symbols

Re: Unable to pass variable filepath

Posted: 2016-04-22T11:20:25-07:00
by fmw42
try

convert -quality 100 -density 500 "$FILE[$PAGES]" page.jpg

I do not know Windows syntax, but I am not sure that $ is a symbol for a variable in Windows. It is for unix.

See http://www.imagemagick.org/Usage/windows/

Also always provide your IM version and platform, since syntax may differ.

Re: Unable to pass variable filepath

Posted: 2016-04-22T14:53:48-07:00
by snibgo
@Mshepelev: what platform are you using (Windows, OSX, bash, whatever)? What version of IM?

If your filepaths contain spaces, you should quote them. On Windows, use double quotes ". On bash, I think it is single quotes '.

Re: Unable to pass variable filepath

Posted: 2016-04-22T18:08:10-07:00
by fmw42
snibgo wrote:@Mshepelev: what platform are you using (Windows, OSX, bash, whatever)? What version of IM?

If your filepaths contain spaces, you should quote them. On Windows, use double quotes ". On bash, I think it is single quotes '.
He is using Windows as far as I can tell, but using unix variable syntax.

On unix, you need to double quote variables or they will not be resolved by single quotes.