NAME

Podius::Property::ScalableImage - Image component property with transformations


SYNOPSIS

Supposed to be used in the Podius::Component manpage and the Podius::Property manpage module trees only.


DESCRIPTION

This module extends Image component property, and adds the ability to apply predefined transformations to the image and create the resulting images (on publish time). Command line utility the convert(1) manpage from ImageMagick package is used for transformations.

The synopsys of all methods and constructors is the same as in the superclasses (Image, Multimedia, Publishable). However the optional hashref parameter of new additionally accepts two keys:

  * exclude_self - boolean flag (default 0), meaning not to publish
    the original image
  * transformations - array of arrays with 2 or 3 elements:
    1) convert-command-line-args (like "-resize 80x80 -quality 30%")
    2) resulting-filename (scalar or sub taking component)
    3) optional label for this transformed image

If convert-command-line-args include only options, then command /usr/bin/convert is assumed. However it is possible to change this default by specifying the first word of the args to be a different executable name, like ``convert'', ``compose'' or ``/usr/bin/compose''.

Additionally, two filename args ``-'' and ``jpeg:-'' (or ``png:-'' accourding to the actual image type) are appended by default, i.e. the convert command reads the input image from stdin and writes it to stdout. The ``-'' argument is not appended if it (or ``type:-'') is already found in the args. Other examples of convert args: ``-resize 600'', ``convert -quality 65 -composite - ./html/images/watermark.png''.

If resulting-filename (the second element of transformations sub-array) ends in trailing slash, then it is considered to be a directory; in this case, the uploaded (stored) basename is appended to this directory to produce the final filename. Similarly, if resulting-filename ends in trailing dot, the extension of the uploaded (stored) file is appended to pruduce the final filename.


REQUIREMENTS

the Podius::Property manpage, the Podius::Property::Publishable manpage, the Podius::Property::Multimedia manpage, the Podius::Property::Image manpage.


UserScalableImage

A sample subclass Podius::Property::UserScalableImage is provided to simplify configuration of user-defined image transformations global to the project. By default there are no transformations (some ready-to-use examples are commented out).

This Podius::Property::UserScalableImage class is copied by default to new projects, it may also be used as an example to define other subclasses of Podius::Property::ScalableImage with alternative image transformations.