Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to use programmatically imagemagick in aem?

Avatar

Level 2

want to Convert image in aem as imagemagic takes realpath(c:\path) but i am unable to provide it.

want to implement in programatically without using CommandLineProcess step.

1 Accepted Solution

Avatar

Correct answer by
Administrator

Hi 

Use JMagick (docs). Read the documentation.

It provides all the functionality of ImageMagick. You may also look into another ImageMagick Java wrapper, im4java.

There is a good starters document for im4java here

//

Here is an example,

/** Typical scaling implementation using JMagick **/ ImageInfo origInfo = new ImageInfo(absPath); //load image info MagickImage image = new MagickImage(origInfo); //load image image = image.scaleImage(finalWidth, finalHeight); //to Scale image image.setFileName(absNewFilePath); //give new location image.writeImage(origInfo); //save

 

Now you just need to create a custom component/Service to achieve the needful.

 

Thanks and Regards

Kautuk Sahni

View solution in original post

2 Replies

Avatar

Level 10

To perform this use case -  you would require a Java API such as the following:

http://im4java.sourceforge.net/

Then use this API within an AEM OSGi to create a service. 

Avatar

Correct answer by
Administrator

Hi 

Use JMagick (docs). Read the documentation.

It provides all the functionality of ImageMagick. You may also look into another ImageMagick Java wrapper, im4java.

There is a good starters document for im4java here

//

Here is an example,

/** Typical scaling implementation using JMagick **/ ImageInfo origInfo = new ImageInfo(absPath); //load image info MagickImage image = new MagickImage(origInfo); //load image image = image.scaleImage(finalWidth, finalHeight); //to Scale image image.setFileName(absNewFilePath); //give new location image.writeImage(origInfo); //save

 

Now you just need to create a custom component/Service to achieve the needful.

 

Thanks and Regards

Kautuk Sahni