Can't convert image file using a bash script

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Boogal
Posts: 8
Joined: 2018-11-11T18:52:05-07:00
Authentication code: 1152

Re: Can't convert image file using a bash script

Post by Boogal »

snibgo wrote: 2018-11-12T18:32:56-07:00 How did you create the shell script file? If you used Windows tools, line-ends are probably marked with carriage-return and line-feed, but bash normally expects just line-feed, and you need to tell it to ignore carriage-return. See IM with Cygwin: Line ends for workarounds.
This solved it, thanks so much.

edit: a friend told me I should add to this in case any future folks find this googling:

I ended up just adding the following to lines to my bash_profile for cygwin:

Code: Select all

export SHELLOPTS
set -o igncr
to universally ignore carriage returns.
Last edited by Boogal on 2018-11-12T19:50:55-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Can't convert image file using a bash script

Post by snibgo »

Good stuff. I suggest you review all my comments in IM with Cygwin. I documented the problems I found, with solutions, to save other people hitting them.
snibgo's IM pages: im.snibgo.com
bratpit
Posts: 17
Joined: 2018-09-16T00:20:21-07:00
Authentication code: 1152

Re: Can't convert image file using a bash script

Post by bratpit »

Read what bash telling you.
est.sh: line 3: -4: substring expression < 0
this means bash not allow negative values in substring expansion.
This works in bash > 4.2.
Probably your bash in Cygwin is < 4.2.


Check this parametr expansion:
${1%.*}palette.png
if not this old-school
works in bash, sh, ash, dash, busybox/ash, zsh, ksh, etc.
${1%?}palette.png
Last edited by bratpit on 2018-11-13T10:32:28-07:00, edited 1 time in total.
bratpit
Posts: 17
Joined: 2018-09-16T00:20:21-07:00
Authentication code: 1152

Re: Can't convert image file using a bash script

Post by bratpit »

duplicate prev. post
Last edited by bratpit on 2018-11-13T10:32:59-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Can't convert image file using a bash script

Post by fmw42 »

This works on my Mac: ${1%.*}

This does not work on my Mac: ${1::-4}

Unfortunately, Apple provides only older versions of bash on my 2014 Mac Mini. My bash is 3.2.57
bratpit
Posts: 17
Joined: 2018-09-16T00:20:21-07:00
Authentication code: 1152

Re: Can't convert image file using a bash script

Post by bratpit »

Fortunatelly there is several ways to do the same in bash :-)
Post Reply