Problem:After upgrading from ImageMagick 6.3.6 (the version bundled with Alf 3.4c) to 6.6.7 all ImageMagick operations fail with "Magick: no decode delegate for this image format" messageInitial env:Out of the box Alfresco 3.4c install on Windows XP - all works fine, image conversions (jpeg to gif thumbnail and jpeg to jpeg resize) execute correctlyChanges: a) Install ImageMagick 6.6.7-1-Q16 b) rename convert.exe to imconvert.exe c) change "img.root=c:/ImageMagick-6.6.7-Q16" and "img.exe =${img.root}/imconvert" in alfresco-global.propertiesAnalysis:The code within Alfresco that executes imconvert can be reduced to
package com.easypress.alfresco.repo.content.transform.magick;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import org.alfresco.util.exec.RuntimeExec.InputStreamReaderThread;
public class ImageMagickContentTransformerWorkerTest {
private static final String IMG_ROOT = "c:/ImageMagick-6.6.7-Q16";
private static final String IMG_DYN = IMG_ROOT;
private static final String IMG_EXE = IMG_ROOT + "/imconvert";
public static void main(String[] args) {
String[] commandToExecute = new String[] {
IMG_EXE,
"c:/temp/ImageMagickContentTransformerWorker_source_test.jpg[0]",
"-thumbnail",
"50%",
"c:/temp/ImageMagickContentTransformerWorker_output_test.jpg"};
String[] processProperties = new String[] {
"MAGICK_HOME=" + IMG_ROOT,
"DYLD_LIBRARY_PATH=" + IMG_DYN,
"LD_LIBRARY_PATH=" + IMG_DYN};
File processDirectory = null;
// Any ONE of these will solve the problem
// String[] processProperties = null;
// String[] processProperties = new String[] { "PATH=" + IMG_ROOT};
// File processDirectory = new File(IMG_ROOT);
try {
Process process = Runtime.getRuntime().exec(commandToExecute, processProperties, processDirectory);
InputStreamReaderThread stdOutGobbler = new InputStreamReaderThread(process.getInputStream(), Charset.defaultCharset());
InputStreamReaderThread stdErrGobbler = new InputStreamReaderThread(process.getErrorStream(), Charset.defaultCharset());
stdOutGobbler.start();
stdErrGobbler.start();
try {
process.waitFor();
} catch (InterruptedException e) {
stdErrGobbler.addToBuffer(e.toString());
}
stdOutGobbler.waitForCompletion();
stdErrGobbler.waitForCompletion();
System.out.println("out: " + stdOutGobbler.getBuffer());
System.out.println("err: " + stdErrGobbler.getBuffer());
} catch (IOException e) {}
}
}
and as this can be executed outside of the Alfresco environment and produce exactly the same result the fundamental problem is how Alfresco is setting up the Runtime.exec() method.The problem is that, for Windows, Alfresco is incompletely replacing the process environment. While ImageMagick may use the MAGICK_HOME property to locate decoders, it uses the standard Windows process to load decoders and that requires the associated .dll to be either on the path or in the current directory.Solution:As given in the code above, there are three possible solutions a) specify the process directory to be ${img.root} (via the processDirectory property to the RuntimeExec bean) b) add PATH=${img.root} to the process properties (via the processProperties property map of the RuntimeExec bean) c) remove the specified process properties and let the process inherit the environment settings (this will only work if ImageMagick has been installed and added to the PATH env)See http://wiki.alfresco.com/wiki/Alfresco_Subsystems for how to over-ride subsystem configurationHope this helps someone!