difference between cmd line & 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?".
Post Reply
DennyC
Posts: 5
Joined: 2017-02-12T11:13:58-07:00
Authentication code: 1151

difference between cmd line & script

Post by DennyC »

Hi...

I have an awk script that I am trying to use convert in and it fails with the following error...

dyld: Library not loaded: /ImageMagick-6.8.9/lib/libMagickCore-6.Q16.2.dylib
Referenced from: /Users/dennis/Applications/ImageMagick-6.8.9/bin/convert
Reason: image not found

if I copy and paste the offending line on the command line it executes just fine...

Here is part of the awk script...

BEGIN{
FS = "/";
}
{
fileName = $NF;
split (fileName, tmpFileName, ".");
sysCmd = sprintf ( "cp %s __TEMPORARY_FILES__/tmpFile.%s", $0, tmpFileName[2]);

sysCmd = sprintf ( "convert __TEMPORARY_FILES__/tmpFile.%s __TEMPORARY_FILES__/tmpFile.eps", tmpFileName[2]);
system (sysCmd);

print ">>";
print ">> "sysCmd;
print ">>";
}

And the output...
dyld: Library not loaded: /ImageMagick-6.8.9/lib/libMagickCore-6.Q16.2.dylib
Referenced from: /Users/dennis/Applications/ImageMagick-6.8.9/bin/convert
Reason: image not found
>>
>> convert __TEMPORARY_FILES__/tmpFile.pgm __TEMPORARY_FILES__/tmpFile.eps
>>


Thanks for every and anyone's help in advance.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: difference between cmd line & script

Post by fmw42 »

try using the full path to convert and to your images
DennyC
Posts: 5
Joined: 2017-02-12T11:13:58-07:00
Authentication code: 1151

Re: difference between cmd line & script

Post by DennyC »

just tried it and its still a problem. Output bellow...


dyld: Library not loaded: /ImageMagick-6.8.9/lib/libMagickCore-6.Q16.2.dylib
Referenced from: /Users/dennis/Applications/ImageMagick-6.8.9/bin/convert
Reason: image not found
>>
>> /Users/dennis/Applications/ImageMagick-6.8.9/bin/convert __TEMPORARY_FILES__/tmpFile.pgm __TEMPORARY_FILES__/tmpFile.eps
>>
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: difference between cmd line & script

Post by fmw42 »

Can you run your IM command in a terminal without error (outside of AWK)?

Are you sure that is the path to convert? What do you get from

Code: Select all

type -a convert
or

Code: Select all

which convert
What do you get from

Code: Select all

convert -version

What is your platform?
DennyC
Posts: 5
Joined: 2017-02-12T11:13:58-07:00
Authentication code: 1151

Re: difference between cmd line & script

Post by DennyC »

Yes... I can run my IM command (convert) in a terminal without any errors outside of AWK. Works very nicely

here is the answers to your questions...

type -a convert
convert is /Users/dennis/Applications/ImageMagick-6.8.9/bin/convert

which convert
/Users/dennis/Applications/ImageMagick-6.8.9/bin/convert

convert -version
Version: ImageMagick 6.8.9-3 Q16 x86_64 2014-06-17 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC
Delegates: bzlib jng jpeg lcms png tiff xml zlib


I am using the Mac version, and I'm running OSX 10.12.2
DennyC
Posts: 5
Joined: 2017-02-12T11:13:58-07:00
Authentication code: 1151

Re: difference between cmd line & script

Post by DennyC »

I simplified the problem to a two line script...

A script of the following fails with the errors listed above.

#!/bin/sh
convert tmpFile.pgm tmpFile.eps


but "convert tmpFile.pgm tmpFile.eps" on the command line works.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: difference between cmd line & script

Post by snibgo »

Does the script run under the same username, with all the same privileges and environment variables as the interactive user?
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: difference between cmd line & script

Post by fmw42 »

try

Code: Select all

#!/bin/bash
/Users/dennis/Applications/ImageMagick-6.8.9/bin/convert/convert tmpFile.pgm tmpFile.eps
Do you have the path to IM in your PATH environmental variable?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: difference between cmd line & script

Post by fmw42 »

Delegates: bzlib jng jpeg lcms png tiff xml zlib
You have no delegates for eps. You probably need ghostscript (and if you have text, then freetype, fontconfig ?)

How did you install IM for you Mac? If from source, then you need to install relevant delegates first. If from binary, then the delegates should be there.

I would recommend installing a binary from MacPorts (or Homebrew).

I install all my delegates from MacPorts and then install IM from source. See viewtopic.php?f=1&t=21502&p=88202&hilit ... rts#p88202
DennyC
Posts: 5
Joined: 2017-02-12T11:13:58-07:00
Authentication code: 1151

Re: difference between cmd line & script

Post by DennyC »

figured it out kids...

its all about... export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib/"

it exists in my .bash_profile so anything I do on the command line it works. Anything I execute in a script (with #!/bin/bash or with awk), the system bash profile has the line missing. If I add the above line to my script it works.
Post Reply