ePages 6.10 - DE_EPAGES/Core/API/Image.pm

Package DE_EPAGES::Core::API::Image

This module provides image functionality.

Example
use DE_EPAGES::Core::API::Image qw( AddBorderToImage NewImage ...);
@EXPORT_OK
ResizeImage
ResizeImageUsingImageRef
NewImage
AddBorderToImage
GetImageInfo
CreateIcon
CorrectImageColorSpace

Functions

AddBorderToImage
CorrectImageColorSpace
CreateIcon
GetImageInfo
NewImage
ResizeImage
ResizeImageUsingImageRef

AddBorderToImage

Add a border with the given params to the image. - Add a border to the image. Then the new was renamed to the target image.

Syntax
AddBorderToImage( $Target, $hParams);
Example
AddBorderToImage( "/tmp/image.gif", {'Height' => 150,
                                     'Width'  => 150,
                                     'BGColor'=>'#FFFFFF'});
Input
$Target (string)
source file
$hParams (ref.hash.string)
possible params are:
  • Height - target image height
  • Width - target image width
  • BGColor (optional) - target image background color

CorrectImageColorSpace

Converts the image color space to RGB if it is not yet an RGB image. Implemented for EPG-11560 to fix CMYK images. To save an additional $Image->Read($File) you can also supply a valid image magick object.

Syntax
CorrectImageColorSpace( $File );
Example
CorrectImageColorSpace( "/tmp/image.gif" );
Input
$File (string)
full file path and name for a image file to be fixed
$Image (object)
image magick object (optional)

CreateIcon

Creates icon from image, the icon includes 3 (16x16,32x32,64x64) sizes.

Syntax
CreateIcon($Image, $Icon);
Example
CreateIcon($Shop->get('PublicPath').'/'.$Shop->get('Logo'), $Shop->get('PublicPath').'/'.'favicon.ico');
Input
$Image (string)
source image file name
$Icon (string)
target icon file name

GetImageInfo

Returns ref.hash with mode, uid and gid for FileName (only unix).

Syntax
GetImageInfo($FileName, $WithExif);
Input
$FileName (string)
file name to get informations from
$WithExif (boolean)
as exif data getting is very expensive, you can use this
parameter to decide, if this function should return the exif information
(optional)
Output
\%FileInfo (ref.hash)
flags
  • Name - filename with Path
  • FileName - filename without Path
  • Extension - extension of file
  • Path - path of file
  • Size - file size in byte
  • LastAccess - DateTime Object
  • LastChange - DateTime Object
  • Height - Height of image
  • Width - Width of image
  • Mimetype - Mimetype "image/extension"
  • Exif - hash with Exif tags (see $WithExif)

NewImage

Create a new image with the given params.

Syntax
NewImage( $Target, $hParams);
Example
NewImage( "/tmp/image.gif", {'Height' => 150,
                             'Width'  => 150,
                             'BGColor'=>'#FFFFFF'});
Input
$Target (string)
source file
$hParams (ref.hash.string)
possible params are:
  • Height - target image height
  • Width - target image width
  • BGColor (optional) - target image background color

ResizeImage

Creates a new image where the maximal width is $ScaleWidth and maximal height is $ScaleHeight.

Syntax
ResizeImage( $Source, $Target, $ScaleWidth, $ScaleHeight, $Quality );
Example
ResizeImage( "/tmp/image.gif", "/tmp/image2.gif", 320, 240, 80 );
Input
$Source (string)
source file
$Target (string)
target file
$ScaleWidth (int)
maximal width of new image (optional)
$ScaleHeight (int)
maximal height of new image (optional)
$Quality (integer)
JPEG quality 0 - 100, (default 100)

ResizeImageUsingImageRef

Like the ResizeImage method, but uses an already open Image::Magick object reference instead of opening the source file. This can be useful when applying more than operation to the image, multiple resize operations for example.

Syntax
ResizeImageUsingImageRef( $Image, $Source, $Target, $ImageWidth, $ImageHeight,
                          $ScaleWidth, $ScaleHeight, $Quality );
Example
ResizeImageUsingImageRef(
    $WorkImage,
    $Source,
    $Path.'/'.$Target,
    $ImageWidth,
    $ImageHeight,
    $hParams->{'SCALE_WIDTH_'.$Size},
    $hParams->{'SCALE_HEIGHT_'. $Size},
    $Quality
);
Input
$SourceImage (object)
image magick object
$Source (string)
source file
$Target (string)
target file
$ImageWidth (int)
width of source image
$ImageHeight (int)
height of new source image
$ScaleWidth (int)
maximal width of new image (optional)
$ScaleHeight (int)
maximal height of new image (optional)
$Quality (integer)
JPEG quality 0 - 100, (default 100)