cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco Transform Ubuntu Script

acurs
Champ in-the-making
Champ in-the-making
Hi,
   I am dealing with a problem when calling a script to do a transformation. I have a script in ubuntu that splits a multipage pdf in single page pdf files, then with convert (from imagemagick) transforms it to tif, then it generates the html with tesseract ocr, convert it back to pdf with the text layer, and merge everythin back into a single pdf with text layer.
The scripts works fine in the console, but in Alfresco, because of different enviroment variables in the path,  use a different convert (/opt/alfresco-3.4.d/common/bin/convert) instead of /usr/bin/convert. The result is a pdf 1.3 instead a tiff so tesseract does not do nothing. The servlet is tomcat, I tried to copy the /usr/bin/convert to catalina home, and to alfresco common directory , rename the convert to conv and call it, etc but nothing happen.

How could I tell Alfresco to use the right convert instead of his /opt/alfresco-3.4.d/common/bin/convert

The script works fine until the convert, but gets executed all:
#!/bin/bash
LANG=eng
FILE=$1
TEMPS=`echo $FILE | md5sum | cut -c 1-32 `
mkdir /tmp/${TEMPS}
cd /tmp/${TEMPS}

echo “Split pages $FILE”
pdftk $FILE burst dont_ask output ${TEMPS}_%04d.pdf

for f in ${TEMPS}_*.pdf
do
f=`basename $f .pdf`
echo “Converting ${f}.pdf to tif”
convert -quiet -density 150 -depth 8 ${f}.pdf ${f}.tif  #ALFRESCO MAKES /COMMON/BIN/CONVERT
done

How could I force to get the right convert
Cheers
2 REPLIES 2

lotharmärkle
Champ in-the-making
Champ in-the-making
I solved this once by removing the environment variables for image magick and also setting the PATH environment variable accordingly. I used a perl script, not bash, but it is the same thing. My suggestion would be to dump
out your environment variables with the command
env
and then set/unset/reset all that starts with MAGICK.
Here is how I did it in my perl script
# fix up env, as alfresco ships its own image magick
foreach my $k (keys %ENV) {
  if($k =~ m/^MAGICK/i) {
    delete $ENV{$k};
  }
}

Dont forget to check and reset the PATH variables as well.


hope that helps,
  lothar

acurs
Champ in-the-making
Champ in-the-making
Excellent I will try this inmediatly….
I could make it work using gs instead of convert, but took me a lot of time to make it work gs command with the params and options behaves weird…

I setted /etc/enviroment, and then source enviroment and started right away