PSD / AI to jpg conversion not working in Cent OS machines
Posted: 2011-07-06T18:23:35-07:00
Hello All,
I've been debugging this issue since 3 weeks. Yet didn't find any clue why this conversion is not working.
Here is what I did :
1. Have a grails application which has a code to convert AI / PSD file to JPG file.
2. This conversion works fine in my local environment.
When I deploy the code in the Cent OS 64 bit machine, conversion is not happening. And no errors too.
-From the command prompt of the Cent OS machine when I give the command. ./usr/bin/convert abc.ai -flatten abc-conv.jpg
the file does get converted and I do see the abc-conv.jpg in the path.
-When it is invoked from the grails application, I don't see the converted .jpg file. I don't see any error in the log file too.
Here's the ImageMagick versions.
Local machine - Windows7 OS :
--------------------------------------------ImageMagick version in local--------------------
C:\grails\helloworld>identify -version
Version: ImageMagick 6.7.0-0 2011-05-20 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
------------------------------------------------ImageMagick version in Cent OS m/c-------------
[root@app2stage:/opt/tomcat/logs] identify -version
Version: ImageMagick 6.7.0-10 2011-07-05 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
--------------------------------------------------------------------------------------------
ImageMagick call -
void convert(String inputPath, String outputPath) {
log.debug("Attempting to convert file ${inputPath}")
def executable = CH.config.externalProcesses.imageMagick.path.toString()
if(CH.config.externalProcesses.imageMagick.home) {
executable = CH.config.externalProcesses.imageMagick.home.toString() + "/bin/convert"
}
log.debug "Using executable ${executable}"
ProcessBuilder pb = new ProcessBuilder(executable,
inputPath, "-flatten",
outputPath)
if(CH.config.externalProcesses.imgeMagick.declareDyldLibPath) {
Map env = pb.environment();
env.put("MAGICK_HOME", CH.config.externalProcesses.imageMagick.home.toString());
env.put("DYLD_LIBRARY_PATH", CH.config.externalProcesses.imageMagick.home.toString() + "/lib");
}
pb.redirectErrorStream(true)
log.debug "command: ${pb.command()}"
Process proc = pb.start()
BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))
StringBuilder sb = new StringBuilder()
def line
while((line = reader.readLine()) != null) {
sb.append(line)
}
sb.append proc.waitFor()
log.debug "conversion output: ${sb.toString()}"
}
-----------------------------------------------
Any idea what could be the problem.
Another clue -
There is another similar method which converts / compresses jpg file to a smaller version of jpg. which works perfectly fine in both local machine and also in the same Cent OS machine. Not sure why the PSD/AI to jpg conversion alone is not working.
Here's the jpg conversion method :
void convert(String inputPath, String outputPath, int width, int height, boolean resize) {
log.debug("Attempting to convert image ${inputPath}")
def dimensions = width + "x" + height
def executable = CH.config.externalProcesses.imageMagick.path.toString()
if(CH.config.externalProcesses.imageMagick.home) {
executable = CH.config.externalProcesses.imageMagick.home.toString() + "/bin/convert"
}
log.debug "Using executable ${executable}"
ProcessBuilder pb = null
if(resize) {
log.debug "resize is set to true"
pb = new ProcessBuilder(executable,
"-depth", "8",
"-resize", dimensions,
inputPath,
outputPath)
} else {
pb = new ProcessBuilder(executable,
"-depth", "8",
inputPath,
outputPath)
}
if(CH.config.externalProcesses.imgeMagick.declareDyldLibPath) {
Map env = pb.environment();
env.put("MAGICK_HOME", CH.config.externalProcesses.imageMagick.home.toString());
env.put("DYLD_LIBRARY_PATH", CH.config.externalProcesses.imageMagick.home.toString() + "/lib");
}
pb.redirectErrorStream(true)
log.debug "command: ${pb.command()}"
Process proc = pb.start()
BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))
StringBuilder sb = new StringBuilder()
def line
while((line = reader.readLine()) != null) {
sb.append(line)
}
sb.append proc.waitFor()
log.debug "conversion output: ${sb.toString()}"
}
I need to resolve this issue ASAP.
Kindly help.
Thanks.
I've been debugging this issue since 3 weeks. Yet didn't find any clue why this conversion is not working.
Here is what I did :
1. Have a grails application which has a code to convert AI / PSD file to JPG file.
2. This conversion works fine in my local environment.
When I deploy the code in the Cent OS 64 bit machine, conversion is not happening. And no errors too.
-From the command prompt of the Cent OS machine when I give the command. ./usr/bin/convert abc.ai -flatten abc-conv.jpg
the file does get converted and I do see the abc-conv.jpg in the path.
-When it is invoked from the grails application, I don't see the converted .jpg file. I don't see any error in the log file too.
Here's the ImageMagick versions.
Local machine - Windows7 OS :
--------------------------------------------ImageMagick version in local--------------------
C:\grails\helloworld>identify -version
Version: ImageMagick 6.7.0-0 2011-05-20 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
------------------------------------------------ImageMagick version in Cent OS m/c-------------
[root@app2stage:/opt/tomcat/logs] identify -version
Version: ImageMagick 6.7.0-10 2011-07-05 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
--------------------------------------------------------------------------------------------
ImageMagick call -
void convert(String inputPath, String outputPath) {
log.debug("Attempting to convert file ${inputPath}")
def executable = CH.config.externalProcesses.imageMagick.path.toString()
if(CH.config.externalProcesses.imageMagick.home) {
executable = CH.config.externalProcesses.imageMagick.home.toString() + "/bin/convert"
}
log.debug "Using executable ${executable}"
ProcessBuilder pb = new ProcessBuilder(executable,
inputPath, "-flatten",
outputPath)
if(CH.config.externalProcesses.imgeMagick.declareDyldLibPath) {
Map env = pb.environment();
env.put("MAGICK_HOME", CH.config.externalProcesses.imageMagick.home.toString());
env.put("DYLD_LIBRARY_PATH", CH.config.externalProcesses.imageMagick.home.toString() + "/lib");
}
pb.redirectErrorStream(true)
log.debug "command: ${pb.command()}"
Process proc = pb.start()
BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))
StringBuilder sb = new StringBuilder()
def line
while((line = reader.readLine()) != null) {
sb.append(line)
}
sb.append proc.waitFor()
log.debug "conversion output: ${sb.toString()}"
}
-----------------------------------------------
Any idea what could be the problem.
Another clue -
There is another similar method which converts / compresses jpg file to a smaller version of jpg. which works perfectly fine in both local machine and also in the same Cent OS machine. Not sure why the PSD/AI to jpg conversion alone is not working.
Here's the jpg conversion method :
void convert(String inputPath, String outputPath, int width, int height, boolean resize) {
log.debug("Attempting to convert image ${inputPath}")
def dimensions = width + "x" + height
def executable = CH.config.externalProcesses.imageMagick.path.toString()
if(CH.config.externalProcesses.imageMagick.home) {
executable = CH.config.externalProcesses.imageMagick.home.toString() + "/bin/convert"
}
log.debug "Using executable ${executable}"
ProcessBuilder pb = null
if(resize) {
log.debug "resize is set to true"
pb = new ProcessBuilder(executable,
"-depth", "8",
"-resize", dimensions,
inputPath,
outputPath)
} else {
pb = new ProcessBuilder(executable,
"-depth", "8",
inputPath,
outputPath)
}
if(CH.config.externalProcesses.imgeMagick.declareDyldLibPath) {
Map env = pb.environment();
env.put("MAGICK_HOME", CH.config.externalProcesses.imageMagick.home.toString());
env.put("DYLD_LIBRARY_PATH", CH.config.externalProcesses.imageMagick.home.toString() + "/lib");
}
pb.redirectErrorStream(true)
log.debug "command: ${pb.command()}"
Process proc = pb.start()
BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))
StringBuilder sb = new StringBuilder()
def line
while((line = reader.readLine()) != null) {
sb.append(line)
}
sb.append proc.waitFor()
log.debug "conversion output: ${sb.toString()}"
}
I need to resolve this issue ASAP.
Kindly help.
Thanks.