问题
I want to run the following script in bash 3.2.57(1):
#!/bin/bash
basename=abc
convert $basename.pdf $basename.png
I get the following error:
dyld: Library not loaded: /ImageMagick-7.0.8/lib/libMagickCore-7.Q16HDRI.6.dylib
Referenced from: /Users/XXX/Applications/ImageMagick-7.0.8/bin/convert
Reason: image not found
./batch_convert.sh: line 22: 46228 Abort trap: 6 convert $basename.pdf $basename.png
When I run the same 2 commands (setting the variable and convert), I get no error.
Why is this happening?
回答1:
Using IM 7.0.8.59 Q16 Mac OSX Sierra, this works for me.
create a pdf
magick logo: logo.pdf
create a script called test.sh
#!/bin/bash
xxx="logo"
magick $xxx.pdf $xxx.png
run script by typing its name in a bash terminal
bash test.sh
Try that and report if that works. I was working from my desktop. So the script and pdf file were on my desktop.
Note that logo: (with the colon) is an ImageMagick internal image. So it is available from anywhere.
来源:https://stackoverflow.com/questions/57349001/imagemagick-error-when-run-from-bash-script-on-mac-osx