ASP.NET, CMS

Image Magick Integration with Sitecore

Image Magick is free software delivered as a ready-to-run as source code that you may use, copy, modify, and distribute in both open and proprietary applications. It is distributed under the Apache 2.0 license.

Requirements:

  1. To convert any Pdf’s specific pages into the jpeg images.
  2. Apply shadow to all converted images.
  3. Rotate each image according to the given angle.
  4. Merge all the images.
  5. Create the Sitecore media library Item of that newly created Image.
  6. Save the image value in the Image filed of the operational item.

 

Implementations and Challenges:

To achieve the above requirement we have divided those in the following tasks.

  1. To convert any Pdf’s specific pages into the jpeg images: 
  • Browse and Save Pdf: Browse the Pdf from the Sitecore media Library and save it .
  • Click Image Magick link: We have created a custom link using core database to link the Image Magick application with Sitecore. In addition, we have created a custom Field type i.e. “Extended Image” (which we have used here for Download Image field).
Sitecore Image Magick menu
Sitecore Image Magick menu
  • Count Pdf’s pages: On click of Image Magick link, it will count the total no. of pages of the saved pdf and a dialogue box will appear in which three text field will get enable according to count of pages. (e.g. if pdf has total 2 pages then only Center and Right Image Number text box will get enable.)

 

Image generation options
Image generation options
  • Provide page no.: We need to provide the specific page no. which we want to convert them into images.
  • Click Preview Image: On clicking preview image, it will convert the given pages no. into the images.

 

  1. Apply shadow to all converted images: After converting pdf pages into Images, we are applying the shadow to each image created. 
  1. Rotate each image according to the given angle: We are rotating each image according to the angle predefined in the code. 
  1. Merge all the images: After rotating each image, we are merging all the images and creating as one image and previewing it.
Preview image generated
Preview image generated

 

In the above case, the images is having transparency so the text is getting overlap. So we will check the “Apply      Background” checkbox.

After checking the checkbox, click Preview Image the above image will get converted as shown below.

Applying Background
Applying Background

 

  1. Create the Sitecore media library Item: On clicking “Generate and Apply” it will create the Sitecore media library Item of that newly created Image. 
  1. Save the image: Close the Dialogue box and save it.

About The Author

Leave a Reply

*