Image Scaling in Liferay

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.

You may also like...

2 Responses

  1. Simon says:

    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 says:

    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 *