Transform a image with Javascript

cancel
Showing results for 
Search instead for 
Did you mean: 
larade
Active Member II

Transform a image with Javascript

Hello,  I have a problem to transform an image. I use a javascript script found in the Alfresco documentation. My version is 5.2.  The script :

// convert an image to JPG format and resize to thumbnail image
var thumbImage = document.transformImage('image/jpeg', '-resize 120');

The log:
ERROR [org.alfresco.repo.jscript.ScriptNode] [defaultAsyncAction4] 08110207 Unsupported transformation: transformer.ImageMagick image/jpeg to image/png

Screenshot :


The image is well converted but the resize does not work. The mimetype (property of the image) can not change.
Being a beginner, I can not understand the log message.
Thank you in advance for your help.
Olivier
13 Replies
mehe
Senior Member II

Re: Transform a image with Javascript

I had a problem with a "duplicate child name" when trying this.

var thumbImage = document.transformImage('image/jpeg', '-resize 120',document.parent.parent);

worked for me and the thumbnail is created on folder above the document (just for testing). But I didn't get the conversion error...

...ok, I first tried your original js-line with a png and everything works. The 120px Thumbnail is created. So it seems to be a problem with the setup.

I used Alfresco Community 5.2 on Ubuntu Linux and the image.magick version provided by alfresco installer for the test.

Regards,

Martin

larade
Active Member II

Re: Transform a image with Javascript

Thank you Martin for your reply :-)


Actually, I had modified the script mimetype line ('image/png'). I had the same error as you concerning the duplicate child name.

I have the same version as you (5.2 Community and the default version of ImageMagick). Did you modify settings particularly?

For additional info, I run the script with a rule on a folder? (as admin)

Did you test the script that way too?

Thanks in any case for your help :-)

Olivier

mehe
Senior Member II

Re: Transform a image with Javascript

I didn't modify any settings - but I installed the "missing libraries" (Installing Linux libraries manually | Alfresco Documentation ) before the Installation of Alfresco. 

When dealing with conversion problems, I add 

log4j.logger.org.alfresco.repo.content.transform.TransformerDebug=debug
log4j.logger.org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker=debug
log4j.logger.org.alfresco.util.exec.RuntimeExecBootstrapBean=debug
log4j.logger.org.alfresco.util.exec.RuntimeExec=debug

to the custom-log4j.properties in tomcat/shared/classes/alfresco/extension

Using the mime types url (.../alfresco/service/mimetypes) you can see which conversions are possible for the configured mime type. The listing for image/jpeg is very long on my system.

Martin

larade
Active Member II

Re: Transform a image with Javascript

Thank you Martin for your responsiveness. I will look at the side of the libraries because I modified the file "custom-log4j.properties" like you without success. I'll let you know. It's amazing anyway.

Olivier
larade
Active Member II

Re: Transform a image with Javascript

Martin,

Can you tell me if you have the same thing when you open in the list "Registered Mimetypes" jpg or png: I have this: Transformable To: Can not be transformed into anything else

Olivier
mehe
Senior Member II

Re: Transform a image with Javascript

As I said above, I have many entries for the conversions:

image/jpeg - jpg

Extractors: org.alfresco.repo.content.metadata.TikaAutoMetadataExtracter
Transformable To:

and so on...

also for png:

image/png - png

Extractors: org.alfresco.repo.content.metadata.TikaAutoMetadataExtracter
Transformable To:

and so on...

also for the "Transformable from" Types.

larade
Active Member II

Re: Transform a image with Javascript

Thanks Martin.  My problem certainly comes from that. I do not have that configuration.
I will look at how to configure this part that is not configured by default in my case. (I'm under microsoft windows)
It going :-)  Thanks again :-)
mehe
Senior Member II

Re: Transform a image with Javascript

looks like image magick isn't working as expected on your installation. Tried to call it directly under Windows? Should work and give no errors.

larade
Active Member II

Re: Transform a image with Javascript

Hi Martin, Thank you for your help because by creating a file "imagemagick-transform-context.xml", I was able to find the settings you have in your file. The conversion works :-) Super! I use a bit but little you tell me when the image is resized if you have the correct exif (width and height). For in my case, the exifs are the same as the original. This causes me a problem because I have to use this image in a software that does not recognize it.  Thanks again Martin, it's really nice to have answered my request.  Olivier