FileWiki

NAME

FileWiki::Plugin::ImageMagick - Image resource creator plugin for FileWiki

SYNOPSIS

PLUGINS=ImageMagick(HIGHRES,LOWRES,THUMB,MINITHUMB)

IMAGEMAGICK_FORMAT                    JPG
IMAGEMAGICK_FORMAT_MINITHUMB          PNG
IMAGEMAGICK_MIME_TYPE                 image/jpeg
IMAGEMAGICK_MIME_TYPE_MINITHUMB       image/png

IMAGEMAGICK_SCALE_THUMB               x180
IMAGEMAGICK_SCALE_MINITHUMB           72x72
IMAGEMAGICK_SCALE_LOWRES              x720
IMAGEMAGICK_SCALE_HIGHRES             2560x1440

IMAGEMAGICK_QUALITY                   75
IMAGEMAGICK_QUALITY_MINITHUMB         50

IMAGEMAGICK_AUTO_ORIENT               1
IMAGEMAGICK_STRIP                     1

DESCRIPTION

Generates images (such as thumbnails and scaled photos) using the Image::Magick module from the ImageMagick software suite.

PLUGIN ARGUMENTS

List of image resource keys. A separate image is generated for each resource key, with the options from the configuration variables.

Plugin Chaining

If an argument starts with the '@' character, the output file of the given resource key is used as input file. If no such argument is present, SRC_FILE is used as input file.

Example:

PLUGINS=ImageMagick(@POSTER,THUMB,MINITHUMB)

This creates a THUMB and MINITHUMB resource from the target image of the POSTER resource (i.e. $page->{RESOURCE}->{POSTER}->{TARGET_FILE}).

CONFIGURATION VARIABLES

IMAGEMAGICK_FORMAT, IMAGEMAGICK_FORMAT_<resource_key>

Specify the file format of the resource target file. If no <resource_key> is provided, the given file format will be used as default for all resources. The file format will also be used as the target file suffix (e.g. ".jpg" for IMAGEMAGICK_FORMAT=JPG).

For a list of supported file formats, see <http://www.imagemagick.org/script/formats.php>.

Example:

IMAGEMAGICK_FORMAT                    JPG
IMAGEMAGICK_FORMAT_MINITHUMB          PNG

This sets the image format to PNG for the MINITHUMB resource, and to JPG for all other resources.

IMAGEMAGICK_MIME_TYPE, IMAGEMAGICK_MIME_TYPE_<resource_key>

Specify the mime type of the resource. If no <resource_key> is provided, the given mime type will be used as default for all resources. If no mime type is defined for a resource, the mime type is guessed from the target file format.

Example:

IMAGEMAGICK_MIME_TYPE                 image/jpeg
IMAGEMAGICK_MIME_TYPE_MINITHUMB       image/png

IMAGEMAGICK_POSTFIX_<resource_key>

Filename postfix of the generated target file. Defaults to lowercase <resource_key>.

IMAGEMAGICK_SCALE, IMAGEMAGICK_SCALE_<resource_key>

Define the geometry "<width>x<height>" of the image resource. The <width> and <height> values specify the maximum dimensions. If either <width> or <height> is zero, the source image is scaled proportionally. Uses ImageMagicks "resize" function (slower than "scale", but produces better output).

Example:

IMAGEMAGICK_SCALE_LOWRES              x720
IMAGEMAGICK_SCALE_HIGHRES             2560x1440

Here, the LOWRES resource is scaled proportionally to a height of 720px. The HIGHRES resource is scaled proportionaly to a maximum width of 2560px and a maximum height of 1440px.

IMAGEMAGICK_XSCALE, IMAGEMAGICK_XSCALE_<resource_key>

Enhanced SCALE. The ratio of the image snaps to common ratios (1:1, 3:2, 4:3, 16:9, 16:10). For portrait images, the given height becomes width. Images smaller than the given height will not be scaled.

IMAGEMAGICK_QUALITY, IMAGEMAGICK_QUALITY_<resource_key>

Set the JPEG/MIFF/PNG compression level (0-100). If no <resource_key> is provided, the compression level will be used as per default for all resources.

IMAGEMAGICK_AUTO_ORIENT, IMAGEMAGICK_AUTO_ORIENT_<resource_key>

If set, adjusts the image so that its orientation is suitable for viewing. If no <resource_key> is provided, the auto orient feature will be enabled per default for all resources.

IMAGEMAGICK_ROTATE, IMAGEMAGICK_ROTATE_<resource_key>

Rotate the image (degrees, clockwise). If no <resource_key> is provided, the rotate feature will be enabled per default for all resources.

IMAGEMAGICK_TINT, IMAGEMAGICK_TINE_<resource_key>

Tint the image with color (e.g. "#FF0000", "rgb(255, 0, 0)").

IMAGEMAGICK_STRIP, IMAGEMAGICK_STRIP_<resource_key>

If set, strips image of all profiles and comments (EXIF data, thumbnails). If no <resource_key> is provided, the strip feature will be enabled per default for all resources.

IMAGEMAGICK_ATTRIBUTE, IMAGEMAGICK_ATTRIBUTE_<resource_key>

Set an image attribute for a resource. If no <resource_key> is provided, the image attribute will be set for all resources. Multiple attributes can be set using array variables (prepending the '+' character).

Attributes are specified using the "<attribute>: <value>" notation. For a complete list of all attributes, see <http://www.imagemagick.org/script/perl-magick.php#set-attribute>.

Example:

+IMAGEMAGICK_ATTRIBUTE  comment: Copyright by Snake Oil Ltd.
+IMAGEMAGICK_ATTRIBUTE  monochrome: True

This sets the image comment to "Copyright by Snake Oil Ltd.", and creates black and white target images.

VARIABLE PRESETS

For each resource, a new entry in the RESOURCE hash is generated:

RESOURCE => {
  ...
  <resource_key> => {
    'NAME'        => <target image name>,
    'URI'         => <target image URI>,
    'MIME_TYPE'   => <target image mime type>,
    'TARGET_FILE' => <target image file>,
    'WIDTH'       => <effective target image width>,
    'HEIGHT'      => <effective target image height>,
    'PLUGIN_NAME' => 'FileWiki::Plugin::ImageMagick',
  }
}

AUTHOR

Axel Burri <axel@tty0.ch>

COPYRIGHT AND LICENSE

Copyright (c) 2011-2019 Axel Burri. All rights reserved.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.