cancel
Showing results for 
Search instead for 
Did you mean: 

How to use ImageMagick API using Java Class

ankit_yakkundi
Champ in-the-making
Champ in-the-making
Hi..
I have installed  Alfresco 3.3 enterprise edition on my Windows XP machine. I know how to use various options like re size,rotate,etc options of  ImageMagick through command line,but i want to know how can i use these options in alfresco so that i can crop,re size the image files from alfresco repository.

I have found some api's, but the problem which i am facing is how to use them through java.
I have referred the following links to solve my purpose.

But i am still confused how to use it. :?
Can anyone help me to attain the objective. :?:
Thanks in advance.. Smiley Happy
9 REPLIES 9

jottley
Confirmed Champ
Confirmed Champ
OTB you can pass command line parameters to ImageMagick as part of the rule (or as part of a script).

If you need something a bit more complex(like if you are merging layers)  You'll need to customize the action.  Basically duplicating the OTB transformer but by customizing the commandline values and then creating the custom UI and Bean components as needed.

http://wiki.alfresco.com/wiki/Content_Transformations (Also see the Related Article links at the bottom of the page)

Jared

ankit_yakkundi
Champ in-the-making
Champ in-the-making
Hi..
Can you please explain whai have to do?? Can you tell me the steps whcih i have to follow.
How can i call the api's through java class file. How to integrate it with alfresco….

these are the doubts..please solve my doubts..

jottley
Confirmed Champ
Confirmed Champ
In most cases there is no Java needed…I would move to java only in corner cases.

Here is a simple walk through, for it we will use the options found in the first example from this page http://www.imagemagick.org/script/command-line-processing.php from the ImageMagick website.

We will run this as an action instead of a rule…but the wizard is pretty much the same.

1/ Access the document details page of a JPG image file.
2/ On the document details page, from the 'Action' list choose 'Run Action'.
3/ On Step One select 'Transform and copy image'  from the 'Select Action' drop down menu.
4/ Click on the 'Set Values and Add' button.
5/ On the page that opens, select the 'Required format'  for the output image type: 'GIF Image'
6/ In the 'Options' text field add: +matte ( +clone -shade 110x90 -normalize -negate +clone -compose Plus -composite ) ( -clone 0 -shade 110x50 -normalize -channel BG -fx 0 +channel -matte ) -delete 0 +swap -compose Multiply
7/ Set the output 'Destination'.
8/ Click the 'OK' button
9/ The 'Next' button will lead you to a summary screen, So we will click on the 'Finish' button to run the action
10/  You will now be back at the Document Details page, so click the 'Close' button.
11/ Navigate to the output destination.
12/ You will see the output image generated with the options passed above.

Jared

ankit_yakkundi
Champ in-the-making
Champ in-the-making
Hi jottley
Thanks for the help.. It worked… But i want to know how can i add watermark to pdf files…
I have used imagemagick as rule…

Any idea or suggestions are welcome…

Thanks in advanced..

ankit_yakkundi
Champ in-the-making
Champ in-the-making
Hi jottley
I want to know whether we can add watermarking to more than one image file at a time??? :?:
For what all types of document we can add watermark, is it only applicable for image files??? :?:

Can we have an action on folder which will add the watermark on all the image files stored on the folder?? :?:  :idea:

Any ideas or suggestions are welcome…

Thanks in advance..

jottley
Confirmed Champ
Confirmed Champ
For images you can add text as a watermark through ImageMagick.  If you want to add an image as the watermark to an image, that will require customizing Alfresco.

If you want to add watermarks to PDF files, you'll need to look at an extension to Alfresco using either pdfbox or iText.

Either of these will require several different customizations:  Custom Action and Custom UI work.

Take a look at http://wiki.alfresco.com/wiki/Custom_Action_UI and at the source code for Alfresco https://svn.alfresco.com/ for the ImageMagick transformer.

Also this on custom transformers http://wiki.alfresco.com/wiki/Content_Transformations

Jared

ankit_yakkundi
Champ in-the-making
Champ in-the-making
Hi..
Thanks for the reply..
But i want to know whether we can add watermark for more than one image files.
Can you tell me what all files i need to change to add new action for the folder which will add watermark to all the files in the folder.Can i get sample code…

Thanks again>>

jottley
Confirmed Champ
Confirmed Champ
You've got a couple of options

1/ Run it as a rule: every time an image is added to the space, a rule is executed that runs the image transformer and creates a watermarked version of the image.

2/ Create a script that can be run against the space the space to execute the transformation against the children of the space. Take a look at this portion of the javascript API  [ulr]http://wiki.alfresco.com/wiki/3.3_JavaScript_API#Transformation_API

The watermarked image would need to be output to a different space.

Jared

ankit_yakkundi
Champ in-the-making
Champ in-the-making
hi..
the first option which you gave , i have implemented that yesterday only..But the problem is thati want to add watermark to pdf, so i thought that when user uploads a pdf file, that pdf file is converted into image files which is then transformed into watermark image file.

Can you suggest me how to do it???? The problem is that when i upload a pdf file, a single image file is created for the pdf file ie only front page of pdf file is transformed into image. How can i create image file for a pdf file ie if a pdf file contains 35 pages, then 35 image files should be created, which can then be watermarked….

Can you also tell me what options can i use to resize the image. If i use thumbnail option then too small image is created.And can we add the watermark text in diagonal rather than horizontal??

Any idea or suggestions are welcome..
Thanks for replying…