ImageMagick – cannot send job

Post Reply
nna
Member
Posts: 30
Joined: Tue Jul 21, 2020 9:57 am

ImageMagick – cannot send job

Post by nna »

Hi all

I've been having issues lately with ImageMagick on Windows Server. Whenever I try to convert anything, the following error is displayed in the messages:

Code: Select all

Cannot send job: path 'E:/Enfocus Switch/temp/1/ScriptElement/109/7/ExecuteComandResult/[i]filename[/i].jpg' does not exist
I've attached a screenshot of my config of the execute command element. It doesn't matter what the inputs and outputs are. Neither PDFs nor image files work as in or outputs. It also doesn't work if my command is simply "%1" "%2" and a output extension that differs from the input extension. Weirdly enough, the exact same flow works perfectly fine on macOS (Big Sur) and works for image files on a Windows 10 PC (not PDF files though). Nothing works on the installation that matters, a Windows Server 2019.

Any help is much appreciated.
Attachments
Bildschirmfoto 2022-03-25 um 14.55.24.png
Bildschirmfoto 2022-03-25 um 14.55.24.png (57.77 KiB) Viewed 15897 times
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: ImageMagick – cannot send job

Post by freddyp »

My advice here is to place everything in a BAT file and in "Command or path" you browse to the BAT file. Below is something from an old BAT file I used that you can easily modify to suit your needs.

Code: Select all

"C:\Program Files\ImageMagick-6.9.2-Q16\convert.exe" %1 -colorspace sRGB -resize 755X774 %2
The thing I always check because I am never 100% certain is whether or not to use quotes in the BAT file, because on OSX it is the other way around. As you can see from the example: no quotes in a BAT file, quotes in a shell script (perhaps now I will remember :) ).

And also note that the %1, %2 and %3 in Switch are placeholders with a certain meaning, the numbers do not say anything about the order in which they are used. There could also be additional parameters, either hard-coded or using variables. In BAT files/shell scripts the %number is about the order of the parameters. So, do not think that %1 maps to %1 etc. If you used this as the "Arguments" in "Execute command":

Code: Select all

"%1" "%2" sRGB
the code in the BAT file would be:

Code: Select all

"C:\Program Files\ImageMagick-6.9.2-Q16\convert.exe" %1 -colorspace %3 -resize 755X774 %2
nna
Member
Posts: 30
Joined: Tue Jul 21, 2020 9:57 am

Re: ImageMagick – cannot send job

Post by nna »

Hi freddy, thank you for your reply. Popping it into a BAT file unfortunately didn't do the trick...

I've got two batch files now, see configuration in the attached screenshot:

Code: Select all

"C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\convert.exe" %1 %2
and

Code: Select all

"C:\Program Files\ImageMagick-6.9.9-Q16\convert.exe" %1 %2
I installed a different version of IM aswell to see if that would change anything but it didn't. It's also not just on my own installation, the same issue occurs on a client's installation... I can't for the life of me figure out what I'm doing wrong :shock:.
Attachments
Bildschirmfoto 2022-04-04 um 14.44.05.png
Bildschirmfoto 2022-04-04 um 14.44.05.png (243.58 KiB) Viewed 15875 times
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: ImageMagick – cannot send job

Post by freddyp »

To the bat cave!

First of all, do not disregard the exit code. Check the value in the ImageMagick documentation.

Run the bat file from Command prompt to see what happens. If it does not run there, it will not run in Switch.

Check the debug messages to see what command was exactly executed and see if there are any anomalies that can explain the problem.

Another thing to consider is that the environment in which CLIs are run in "Execute command" is not the same as when you do it in Command prompt or Terminal. The path variable could be different for example, so some dependency could be found in Command prompt/Terminal but not in "Execute command". Add the path to where Imagemagick is installed to the beginning of the BAT file:

Code: Select all

set PATH=%PATH%;C:\Program Files\ImageMagick-6.9.2-Q16
Well, with whatever version you want to point to of course. And it is also no longer required to specify the full path when running convert.exe.
nna
Member
Posts: 30
Joined: Tue Jul 21, 2020 9:57 am

Re: ImageMagick – cannot send job

Post by nna »

So, I fixed it. I ran the command in the Windows command prompt and got an error. "convert.exe: FailedToExecuteCommand "gswin64c.exe" blablabla". I found this stackoverflow post where someone got the same error: https://stackoverflow.com/questions/324 ... exe-pdfdel
The solution was to separately install Ghostscript. I've installed it from here: https://www.ghostscript.com/releases/gsdnld.html
And now it works again! Thanks for your help, freddy!
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: ImageMagick – cannot send job

Post by freddyp »

I should have mentioned it, because indeed ImageMagick uses Ghostscript for reading PDFs so you have to have Ghostscript installed.

But there is more to it. ImageMagick simply runs "gscwin64c.exe" (as you can see from the error message), which will only work if the path to Ghostscript is present in the PATH variable. If the Ghostscript installation did that globally for all users all will be well, but if that is not the case you must add that to the BAT file.
nna
Member
Posts: 30
Joined: Tue Jul 21, 2020 9:57 am

Re: ImageMagick – cannot send job

Post by nna »

I'm reviving this thread because I'm experiencing the issue again on a different installation (Windows 10 Enterprise). Ghostscript is installed and the outcode is 0, so I have to assume the conversion works. If I run the command from Command prompt, it works as expected. I can convert PDFs to JPG, EPS to JPG and EPS to EPS. But the same command doesn't work in Switch. The code is correctly executed according to the Switch messages, stderr and stdout are empty. And yet, the Cannot send job error persists. Any ideas what might cause this?
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: ImageMagick – cannot send job

Post by freddyp »

I think I answered it in my previous reply: the PATH variable should include the location of Ghostscript (and also ImageMagick of course).
nna
Member
Posts: 30
Joined: Tue Jul 21, 2020 9:57 am

Re: ImageMagick – cannot send job

Post by nna »

freddyp wrote: Mon May 02, 2022 3:31 pm I think I answered it in my previous reply: the PATH variable should include the location of Ghostscript (and also ImageMagick of course).
Because the conversion seems to work according to the messages (no FailedToExecuteCommand), I think it's something else. Either way, since I'm not well versed in batch scripting, what should that bat-file look like?
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: ImageMagick – cannot send job

Post by freddyp »

Something like this where of course you will have to use the paths on your system and with the ImageMagick command you want to run:

Code: Select all

set PATH=%PATH%;C:\Program Files\ImageMagick-6.9.2-Q16;C:\Program Files\gs\gs9.16\bin
convert.exe" %1 -colorspace sRGB -resize 755X774 %2
Note that %1 and %2 are the first and second parameters passed in "Arguments". In this case they correspond to "%1" and "%2" in Switch but that is not mandatory.
nna
Member
Posts: 30
Joined: Tue Jul 21, 2020 9:57 am

Re: ImageMagick – cannot send job

Post by nna »

Thanks! Unfortunately, this throws an outcode 4 with the message that -density is an invalid parameter. I see in the debug messages that even without the PATH variable, Switch gets the correct application paths. I've now opted to using the setup in my initial post here and that works as expected. But if I now choose the output extension to be EPS, the initial warning appears again. My input file is a non-vector EPS...
nna
Member
Posts: 30
Joined: Tue Jul 21, 2020 9:57 am

Re: ImageMagick – cannot send job

Post by nna »

As I'm still looking to solve this problem, I tried a few things. This is my current error with outcode 1.

Code: Select all

stderr: convert: unable to open image '"C:\Users\publishing\AppData\Roaming\Enfocus\Switch': Invalid argument @ error/blob.c/OpenBlob/3533.; convert: unable to open image 'Server\backing\EPStoEPS\automanaged\Folder': No such file or directory @ error/blob.c/OpenBlob/3533.; convert: unable to open image 'Server\backing\EPStoEPS\automanaged\Folder': No such file or directory @ error/blob.c/OpenBlob/3533.; convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/738.; convert: unable to open image '2\_0003F_b1761_h.eps"': No such file or directory @ error/blob.c/OpenBlob/3533.; convert: unable to open image '2\_0003F_b1761_h.eps"': No such file or directory @ error/blob.c/OpenBlob/3533.; convert: no decode delegate for this image format `EPS"' @ error/constitute.c/ReadImage/738.; convert: no images defined `C:\Users\publishing\AppData\Roaming\Enfocus\Switch Server\temp\6\ScriptElement\6\5\ExecuteComandResult\b1761_h.eps' @ error/convert.c/ConvertImageCommand/3325.
And these are my arguments

Code: Select all

convert EPS:"%1" -density 72x72 "%2"
Weirdly enough, if I execute the same command in the command line on Windows, it works... Any ideas?
Post Reply