I got a request to make synchronization of profile images from SuccessFactor to Active Directory for a client. Pictures can be uploaded in different sizes in SuccessFactors and it will be deficult to understand if they have the correct sizes for the AD system.
I, therefore, wanted to implement a resize mechanism that allowed users to resize single images to a square size.
We could not resize the image, but we needed to Crop it so we keep the dimensions of the person. Nobody wants to have a stretched image.
To resize the image without losing too many details and we decided to use the Simple Java image-scaling library imgscalr that allows easy access to convert the images. The script is then embedded into an iflow with Process Direct adapter. This way it can be embedded into multiple different application or just your single application. It is a pretty simple flow as seen below.
When calling the process direct adapter with the endpoin /figaf/imageresizer you need to set the size as a header and then the image as payload.
The code for conversion is the following.
You can download the iflow here.
I do have a course that helps you learn SAP CPI. Check out the free course on the page.