---
title: "Image scaling with Jahia part 1"
url: "https://www.jahia.com/sites/jahiacom/contents/Blog/Entries/image-scaling-with-jahia-part-1.html"
description: "In 2013, should you double your resolutions? Read our technical blog to get the latest information and full insight about Jahia technologies."
last_updated: 2026-07-20
---

# Image scaling with Jahia part 1

Jahia TeamMay 26, 2014

In the previous blog post about the rule engine we have illustrated how it interacts with Jahia and shown that the rule engine acts upon changes within the content repository and is integrated at a JCR event listening level. Since all content is stored within the JCR this also includes images so it’s possible to do image manipulation each time a user uploads content into Jahia.
One of the reasons why we might manipulate an image is to ensure that we don’t send back enormously large images uploaded by the content managers and re-scale them back to a maximum size. Other reasons why we want to manipulate a image is when we want to watermark or when a module requires an image to be re-scaled to some predefined size like thumbnails or always square, like profile images.

## Image manipulation in the document manager

During installation of Jahia, you might have noticed a question on the *Document Management Tools* dialog what sort of tools you have available. One of them is your Image Magick installation and you can set this to the path of your IM installation: If you missed this during installation and the install tool didn't find its location correctly you can always set it later.

Simply edit the file tomcat/webapps/ROOT/WEB-INF/etc/config/jahia.properties and modify the variables under *Image conversion Service*

```
######################################################################
### Image conversion Service #########################################
######################################################################
# The image service to use
# Native java service : "ImageJAndJava2DImageService"
# Set to "ImageMagickImageService" to use ImageMagick. You'll then have to set
# the imageMagick path
imageService = ImageMagickImageService
# The path to image magick and exiftools
# For windows : C:\\Programs\\ImageMagick;C:\\Programs\\exiftool
imageMagickPath = /opt/local/bin
```

For image manipulation Jahia can use both [Image Magick](http://www.imagemagick.org) or [GraphicsMagick](http://www.graphicsmagick.org) and the [library im4java](http://im4java.sourceforge.net) is used. If for some reason it’s impossible to install any of the two libraries Jahia can use a native version, but be aware that some image manipulation functions might not work very well due to its limited capabilities, notably transparent PNG’s might show odd results.

## Jahia’s default thumbnails rule

As you may have noticed, Jahia already has a built in rule to process any updated image and store extracted meta data in the JCR, additionally what happens is that Jahia will create two thumbnails of size 150 and 350px so in the backend it can show previews of uploaded images. To see what Jahia created for you simply go to the URL [http://localhost:8080/tools/jcrBrowser.jsp](http://localhost:8080/tools/jcrBrowser.jsp). Then under /sites/<sitename>/files find a image and click on that image.

There are two thumbnail nodes created for an uploaded image from my digital camera. You can even call them up by appending to the node path of the image the ’t’ parameter. For example: http://localhost:8080/files/{workspace}/sites/mySite/files/DSC06733.jpg?t=thumbnail2

## Examples

Let’s create some example to demonstrate some of the concepts.

### Example 1:

**Task:** When an image is uploaded, rescale this image to 800px Re-sizing a photo is common practise whenever you upload general photo’s and you want to display a smaller size, and a bigger size, but not the uploaded version that can potentially be big.

This is very simple to do, Jahia already has a build in image service we can use, all we have to do is create a rule for this task. I actually just copied the rule over from /webapps/ROOT/modules/default/META-INF/rules.drl and modified it to fit my needs

```
rule "Blog Image Scaling - 800px"
    salience 25
    when
        A file content has been modified
             - the mimetype matches image/.*
    then
        > long timer = System.currentTimeMillis();
        Create an image "800px" of size 800
        Dispose image
        Log "Blog Image Scaling 800px : Image " + node.getPath() + " updated in " + (System.currentTimeMillis() - timer) + " ms"
end
```

When we upload the image, now a 800px version will be created and can be called with the following URL: [http://localhost:8080/files/{workspace}/sites/mySite/files/DSC06733.jpg?t=800px](http://localhost:8080/files/live/sites/mySite/files/DSC06733.jpg?t=800px)

### Example 2:

**Task:** Create a crop-scaled version of an image
Crop scaling is often required for profile style pictures. This will ensure that nobody can upload incorrectly sized photo’s and that a profile page always looks nice and tidy. Essentially it takes the maximum square of a image and scales it down to a required size.
Again we need a rule for this but unfortunately there wasn’t a ready made consequence for us. Luckily, we can still call the ImageService directly and do our task, here is how it will look like:

```
rule "Blog Image Scaling - square 120px"
    salience 25
    when
        A file content has been modified
             - the mimetype matches image/.*
    then
        > long timer = System.currentTimeMillis();
        > imageService.addThumbnail(node, "sq120px", 120, true, drools);
        Dispose image
        Log "Blog Image Scaling square 120px : Image " + node.getPath() + " updated in " + (System.currentTimeMillis() - timer) + " ms"
end
```

To load the square thumbnail we can use this URL: [http://localhost:8080/files/{workspace}/sites/mySite/files/DSC06733.jpg?t=800px](http://localhost:8080/files/live/sites/mySite/files/DSC06733.jpg?t=800px)
In the next blog post we will take this a step further by creating our own node type and re-scale a image according to the user settings. We will also create a special folder where you can upload images and they will be re-sized to a size as set by an administrator.

This blogpost has been written by [R. van Twisk](https://www.linkedin.com/in/riesvantwisk/)

### Jahia Team

Discover

## Related resources

[Video jExperience Overview: 1/5/2026 Discover jExperience, Jahia’s personalization solution, and learn how to deliver content tailored to customer journeys and profiles.](https://www.jahia.com/resources/videos/jexperience-overview) [BlogBlog Blog: 11/20/2025](https://www.jahia.com/blog) [Blog 10 Benefits of Digital Asset Management (DAM) in 2026: 9/12/2025 Digital asset management saves time, cuts costs, ensures brand consistency, boosts collaboration, and secures your content.](https://www.jahia.com/blog/10-benefits-of-digital-asset-management-dam-in-2026) [Blog What is Digital Asset Management (DAM)? 8/28/2025 Digital asset management (DAM) centralizes, organizes, and secures digital files, helping teams save time, cut costs, and stay brand-consistent.](https://www.jahia.com/blog/what-is-digital-asset-management-dam) [Blog Enterprise CMS vs. Simple CMS: What’s the difference? 8/21/2025 Accelerate growth with an Enterprise CMS: speed, security, multilingual, cloud power, and limitless personalization.](https://www.jahia.com/blog/enterprise-cms-vs-simple-cms-whats-the-difference) [Blog Enterprise CMS: Definition, Key Features and Benefits: 8/14/2025 Struggling with slow content, poor SEO, and scaling issues? See how an Enterprise CMS can transform your digital performance.](https://www.jahia.com/blog/enterprise-cms-definition-features-and-key-benefits) [Blog 10 strategic criteria for choosing the best enterprise CMS: 8/7/2025 Most companies choose the wrong CMS. Don't make the same mistake, find out what they wish they knew before it was too late.](https://www.jahia.com/blog/10-strategic-criteria-for-choosing-the-best-enterprise-cms) [Blog Digital asset management vs document management: 2/27/2025 Discover the difference between DAM and DMS. Learn how these tools streamline digital content management to organize creative assets or critical business documents.](https://www.jahia.com/blog/digital-asset-management-vs-document-management) [Blog Using Digital Asset Management Integrations: 12/4/2024 Digital Asset Management (DAM) integrations enhance your CMS platform. Learn how using integrations can streamline workflows, boost efficiency, and improve team collaboration.](https://www.jahia.com/blog/using-digital-asset-management-integrations)
