Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

CommmandLineProcess : ImageMagick

Avatar

Level 3

I am trying to use CommmandLineProcess  step to flip an image using imageMagick commands. I have installed the imageMagick software on my machine and able to execute the commands on command prompt and operate on the images on my system, But when i configure a command in AEM CommandLineProcess step in a workflow and execute the workflow for an image i get the below error

 

09.06.2015 16:14:51.433 *INFO* [JobHandler: /etc/workflow/instances/2015-06-09/model_109813702252312:/content/dam/geometrixx/portraits/yolanda_huggins.jpg] com.day.cq.dam.core.process.CommandLineProcess execute: executing command line [convert C:\Users\MMANJA~1\AppData\Local\Temp\cqdam3684189622130797275.tmp/yolanda_huggins.jpg -flip C:\Users\MMANJA~1\AppData\Local\Temp\cqdam3684189622130797275.tmp/yolanda_huggins.flipped.jpg] for asset [/content/dam/geometrixx/portraits/yolanda_huggins.jpg].
09.06.2015 16:14:51.461 *ERROR* [JobHandler: /etc/workflow/instances/2015-06-09/model_109813702252312:/content/dam/geometrixx/portraits/yolanda_huggins.jpg] com.day.cq.dam.core.process.CommandLineProcess execute: failed to execute command [convert C:\Users\MMANJA~1\AppData\Local\Temp\cqdam3684189622130797275.tmp/yolanda_huggins.jpg -flip C:\Users\MMANJA~1\AppData\Local\Temp\cqdam3684189622130797275.tmp/yolanda_huggins.flipped.jpg] for asset [/content/dam/geometrixx/portraits/yolanda_huggins.jpg]:  org.apache.commons.exec.ExecuteException: Process exited with an error: 4(Exit value: 4)
    at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:346)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:149)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:136)
    at com.day.cq.dam.core.process.CommandLineProcess.execute(CommandLineProcess.java:235)
    at com.day.cq.workflow.compatibility.CQWorkflowProcessRunner.execute(CQWorkflowProcessRunner.java:93)
    at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:208)
    at com.adobe.granite.workflow.core.job.JobHandler.process(JobHandler.java:139)
    at org.apache.sling.event.jobs.JobUtil$1.run(JobUtil.java:378)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

 

Below is the command

convert ${directory}/${filename} -flip ${directory}/${basename}.flipped.jpg

 

I have attached the screenshot of the dialog properties i have configured

I have verified the permissions for the folder it looks fine. Any help is appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 10
9 Replies

Avatar

Correct answer by
Level 10

Avatar

Level 2

Hi Murli,

   did you got this issue resolved? I am facing the same issue and i am getting below error''java.io.IOException: Cannot run program "convert" (in directory "/var/folders/fv/m83vzmp15yx61zk8dphr9qhc0000gp/T/cqdam7524535527327291654.tmp"): error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
    at java.lang.Runtime.exec(Runtime.java:617)
    at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
    at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:246)
    at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:302)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:149)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:136)
    at com.day.cq.dam.core.process.CommandLineProcess.execute(CommandLineProcess.java:235)
    at com.day.cq.workflow.compatibility.CQWorkflowProcessRunner.execute(CQWorkflowProcessRunner.java:93)
    at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:184)
    at com.adobe.granite.workflow.core.job.JobHandler.process(JobHandler.java:232)
    at org.apache.sling.event.impl.jobs.JobConsumerManager$JobConsumerWrapper.process(JobConsumerManager.java:512)
    at org.apache.sling.event.impl.jobs.queues.JobRunner.run(JobRunner.java:205)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:185)
    at java.lang.ProcessImpl.start(ProcessImpl.java:130)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)
    ... 15 common frames omitted

 

Pavan

Avatar

Level 10

basically, I think you need to replace ${filename} with the actual filename and similarly for basename and directory as per the example given in the above article 

Avatar

Level 3

I referred to the same link to implement this and followed the same steps and ended up getting this issue.

Avatar

Level 3

${filename} $ {directory} are implicit that is the reason in the stack trace it picks up the image path correctly as highlighted ib bold below

[convert C:\Users\MMANJA~1\AppData\Local\Temp\cqdam3684189622130797275.tmp/yolanda_huggins.jpg -flip C:\Users\MMANJA~1\AppData\Local\Temp\cqdam3684189622130797275.tmp/yolanda_huggins.flipped.jpg] for asset [/content/dam/geometrixx/portraits/yolanda_huggins.jpg]: 

 

Even if i specify absolute path of an image on my machine it throws same error.

Avatar

Level 1

Hi,

 

I faced similar issue. This is because 'convert' command is not getting executed through AEM even if it executes from your command prompt. 

For this you need to specify the installation folder of ImageMagick to make it execute.

"C:\Program Files\ImageMagick-6.8.9-Q16\convert.exe" -define jpeg:size=319x319 ${filename} -thumbnail 319x319 cq5dam.thumbnail.319.319.png.

or

C:\Program Files\ImageMagick-6.8.9-Q16\convert -define jpeg:size=319x319 ${filename} -thumbnail 319x319 cq5dam.thumbnail.319.319.png.

Avatar

Level 1

Hi Murali,

Was this issue resolved? I am getting the same error (org.apache.commons.exec.ExecuteException: Process exited with an error: 4(Exit value: 4)) and not able to figure out the root cause.

Avatar

Level 1

Got it working by using the full path for the convert command of ImageMagick installtion directory "C:\Program Files\ImageMagick-6.8.9-Q16\convert.exe"

Avatar

Level 1

Hi bsloki

I'm trying to get it working on Linux server. Are there any specifics. I could not find a single article for ImageMagick in AEM on Linux. Can you please guide me to any documentation available. Thanks a lot.