imagemagick error when run from bash script on Mac OSX

北城以北 提交于 2019-12-13 03:36:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!