Image Scaling in Liferay

Liferay Logo

Have you ever wondered if Liferay offer image scaling out of the box? Yes it does, you only need to enable this option!

In portal-ext.properties add:

image.auto.scale=true
image.hook.impl=com.liferay.portal.image.DLHook

The second property image.hook.impl sets the hook implementation to be used to trigger automatic data migration during an upgrade.

Requesting Scaled Images

Now in order to request scaled images simply use height and width as GET parameters, like so:

http://localhost:8080/image/journal/article?img_id=x&height=y&width=z

Caching

For performance reasons Liferay caches scaled images. Please refer to ImageUtil API for more information.

Further Readings

Further information can be obtained by consulting the Image section in the Liferay Portal 6.1 – User Guide.

Comments

2 responses to “Image Scaling in Liferay”

  1. Simon Avatar
    Simon

    It looks like the JPEG compression ratio is set to a very low value. The resulting image quality is horrible. Is there a way to set this?

  2. Simon Avatar
    Simon

    The endpoint doesn’t seem to be protected in any way. An attacker could fill the server hard drive by just requesting lots of different large versions of an image.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.