Page 1 of 1

PSD / AI to jpg conversion not working in Cent OS machines

Posted: 2011-07-06T18:23:35-07:00
by imageconvert
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.

Re: PSD / AI to jpg conversion not working in Cent OS machin

Posted: 2011-07-06T18:31:41-07:00
by magick
Does the conversion work from the command-line? Sometimes conversions work from the command-line but not from a program / script due to differences in the environment.

Re: PSD / AI to jpg conversion not working in Cent OS machin

Posted: 2011-07-08T17:50:47-07:00
by imageconvert
Hi Magick,

Thanks for your quick response. Actually, it was working on command line but not from the grails application. But to my surprise it works now.

Now, my problem is that :
1. AI to jpg file is not converting properly on the Cent OS machine. But it converts fine on my local windows 7 machine.
Original AI file size : 2.24 MB (2,353,316 bytes)
Converted jpg file size (Cent OS) : 23.3 KB (23,951 bytes) -> Distorted
Converted jpg file size (Windows) : 346 KB (354,912 bytes)

2. PSD to jpg conversion works fine on the Cent OS machine. Where as it converts into a distorted jpg file on my windows 7 machine.
Original PSD file size : 11.1 MB (11,735,352 bytes)
Converted jpg file size (Cent OS) : 1.83 MB (1,924,758 bytes)
Converted jpg file size (Windows) : 2.08 MB (2,186,564 bytes) -> Distorted

The command that I use in all cases is : convert <<source file name ai/psd>> -flatten <<target file name jpg>>
ie., convert abc.ai -flatten abc.jpg
convert abc.psd -flatten abc.jpg.

Can you please let me know what's going on here. Let me know if you need more information from me.

Re: PSD / AI to jpg conversion not working in Cent OS machin

Posted: 2011-07-08T18:12:08-07:00
by fmw42
I am not an expert on this. But things to check might be:

1) do you have the same versions of IM on both machines
2) do you have ghostscript installed and the same versions on both machines

convert -list configure

Look at the line DELEGATES and see if gs is listed

In unix, you can type

gs -version

and check the version

For IM, type

convert -version