Media Conversion in SAP Hybris
Hey friends ! This blog post covers the concept of Media Conversion using a third-party tool which can be integrated to Hybris for conversion of Medias.
We might go through cases, where we need several media formats for the same image, like image of dimensions 1200Wx1200H and same image with different dimensions like a 515×515 or 96×96 or any other as per our requirement.
Hybris allows third party open source software suite for converting the Medias to required formats. Here we are going to see how the third party tool ‘ImageMagick’ can be used within Hybris for Media Conversion.
1) Download and Install ImageMagick
First you need to install the ImageMagick , for downloading go to http://www.imagemagick.org. Download the software as per your OS configurations.
Install the software in your system.
You can now see it installed in the corresponding drive.
2) Configure the ImageMagick path in Hybris system
Configure below 2 properties in local.properties file.
imagemagick.bindir
imagemagick.configuration.directory
3. Media conversion in HMC
Below are the action items that are needed for Conversion of a media in required formats.
a. Create source media.
b. Create conversion formats.
c. Create conversion group.
d. Create media container and assign the media and conversion group.
a) Create media
You can create a media by following our previous blog (https://blogs.sap.com/2016/11/30/media-creation-in-sap-hybrisdigital-asset-management/ )
Here I have created a media Test_Media_Convert having media format 1200×1200 as shown below.
b) Create Media Conversion Formats.
Now this is the main step, here you define your own media format(for example resizing the medias to particular format).
Go to Multimedia->Media Format->Create->Conversion Media Format.
Provide a unique qualifier name, and other details as shown below.
Conversion Strategy: Here the Conversion Strategy will be populated by default initially. As we are using the same ImageMagick, we shall keep this same.
Conversion Command: We need to provide the commands as per the format is required.
In below image, I am creating a format of 300×300, hence I provide the command as -resize 300×300. This is the command syntax for ImageMagick.
For more commands check here http://www.imagemagick.org/script/command-line-processing.php
Click on Create and then Save.
I have created one more Media Conversion Format for 96×96.
c) Creating Conversion Group
Conversion Group is just to group the required Media conversion formats. Follow below steps to create one.
Provide the details.
Add the created Conversion Media Formats in step b) in Supported Formats area as shown below.
Click on Create and Save.
d) Creating Media Container and assigning Media and Conversion Group
Provide the required details and the Media created in step a.
Click on the Search icon for adding the Conversion Group that was created in step c.
Search for the conversion group, select it and click on Use button.
You can see the Conversion Group (Test_Conversion_Group) is assigned. Click on Create and then Save.
Initially before saving, the button Convert missing medias was disabled.
Now after saving you can see, the button is enabled.
Click on ‘Convert missing medias’ button.
By doing this, the conversion group that has the conversion media formats are executed and the commands are triggered.
Below pop-up would come.
Click on Close Window.
Now you can see, 2 more medias are created of sizes 300×300 and 96×96.
These are the converted medias per the ImageMagick commands given in Conversion formats.
So that was the Media Conversion concept with example. Hope this was helpful.
Thanks for reading ! Will be back with another concept in next blog.
It is a very good, basic and easy to understand document for integrating Imagemagick with Hybris.
I’m having doubt while using this converted medias in product. I’m not able to get the image in storefront. However, image displays only after changing the media format(from convert_300x300 to default 300Wx300H). How to overcome this issue?.
Also, I would like to keep the copy of converted media in sample data? is it possible?. Because, How could we automate the process?
Hi Venkatesh,
Did you ever get a reply or found a solution on your question? I also noticed the storefront only shows images with e.g. 300Wx300H or 96Wx96H for thumbnail as format but not the ConversionMediaFormat that one uses to convert them via Imegamagick.
I am running into the same issue and looking forward to a solution.
Very use full information
Could you give us detail steps in order to execute this point 2) Configure the ImageMagick path in Hybris system
Amazing.