API
Version 7.x > API > Image resizing functionality View modes: 
User avatar
Member
Member
Jonathontek-gmail - 1/19/2013 10:07:17 PM
   
Image resizing functionality
Hi,
I am wondering if Kentico provides an api class that assists in resizing of images.

I have a daily data feed that imports sales data through a scheduled task, some of the data that is pulled in is associated with images. These images are moved into a folder within the site structure. The way that I have set up this functionality is external from Kentico, meaning that Kentico doesn't know about these images. They are not linked with a media gallery or document type. They just sit within the directory structure. Basically the data coming in is used to create reports and the images will be links off these reports. What I need is, when I move the images (jpg, jpeg) into the <site name>\Images\ folder I need to check if the images are greater that xx wide and if so resize before moving. This will help keep the size of the site down as there may be a large number of images coming in.

I cannot find any api examples that allow me to do this. I can find other c# code but would like to use the api if possible.

Thanks in advance.

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 1/20/2013 11:21:36 AM
   
RE:Image resizing functionality
The default usage of our file management means allow to use resizing on upload

Generally, we use the AttachmentManager methods for resizing attachments and files. It utilizes CMS.GlobalHelper.ImageHelper class methods for the image processing itself.
The methods usage can be seen in our pages or controls codefiles and they should be offered in VisualStudio or seen in API reference

You can see how the attachments (images) are resized e.g. in the /CMSPages/GetFile.aspx.cs script. Here, for example the EnsurePhysicalFile method either points to an existing thumbnail image file or creates a new one of the required dimensions (see image size parameters for getfile script)

You maybe want to replace the original image file with the resized (typically shrinked) one instead of creating a thumbnail images, and also do it completely independent on our file management means, so you will be probably working just with binary file data (used to instantiate an Image object) and overwriting the original file with the resized image data. Then the ImageHelper with standard file operation methods should be sufficient for your aim.

Regards,
ZdeneK

User avatar
Member
Member
belindaharris897-hotmail - 11/28/2013 8:53:40 PM
   
RE:Image resizing functionality
I'm not familar with Kentico image resizing program, but I can recommend you this image resizing api of an .net image gallery, you can call the method to program your own image resizing project for it comes from a third party. You can choose to resize image automatically or manually.