Omeka_File_Derivative_Image_Creator

class Omeka_File_Derivative_Image_Creator

Package: File\Derivative

Create derivative images for a file in Omeka.

property _convertPath
property _identifyPath
property _derivatives
__construct($imDirPath)
Parameters:
  • $imDirPath (unknown) –
setImageMagickDirPath(string $imDirPath)

Set the path to the ImageMagick executable.

Parameters:
  • $imDirPath (string) – Path to the directory containing the ImageMagick binaries.
getConvertPath()

Get the full path to the ImageMagick ‘convert’ command.

Returns:string
getIdentifyPath()

Get the full path to the ImageMagick ‘identify’ command.

Returns:string
create(string $fromFilePath, string $derivFilename, string $mimeType)

Create all the derivatives requested with addDerivative().

Parameters:
  • $fromFilePath (string) –
  • $derivFilename (string) –
  • $mimeType (string) –
Returns:

boolean

addDerivative(string $storageType, integer|string $size, boolean $square =)

Add a derivative image to be created.

Parameters:
  • $storageType (string) –
  • $size (integer|string) – If an integer, it is the size constraint for the image, meaning it will have that maximum width or height, depending on whether the image is landscape or portrait. Otherwise, it is a string of arguments to be passed to the ImageMagick convert utility. MUST BE PROPERLY ESCAPED AS SHELL ARGUMENTS.
  • $square (boolean) – Whether the derivative to add should be made square.
_createImage($origPath, $newPath, $convertArgs)

Generate a derivative image from an existing file stored in Omeka.

This image will be generated based on a constraint given in pixels. Forexample, if the constraint is 500, the resulting image file will be scaledso that the largest side is 500px. If the image is less than 500px on bothsides, the image will not be resized.

Derivative images will only be generated for files with mime typesthat can be identified with ImageMagick’s ‘identify’ command

Parameters:
  • $origPath (unknown) –
  • $newPath (unknown) –
  • $convertArgs (unknown) –
_getResizeCmdArgs(integer $constraint, boolean $square)

Get the ImageMagick command line for resizing to the given constraints.

Parameters:
  • $constraint (integer) – Maximum side length in pixels.
  • $square (boolean) – Whether the derivative should be squared off.
Returns:

string

_isDerivable(string $filePath)

Returns true only if ImageMagick is able to make derivative images of that file based upon whether or not it can be identified by ImageMagick’s ‘identify’ binary. Otherwise returns false.

Parameters:
  • $filePath (string) –
Returns:

boolean

_isIdentifiable(string $filePath)

Returns true only if the file can be identified by ImageMagick’s ‘identify’ binary

Parameters:
  • $filePath (string) –
Returns:

boolean

isValidImageMagickPath($dirToIm)

Determine whether or not the path given to ImageMagick is valid. Both the convert and identify binaries must be within the directory and executable.

Parameters:
  • $dirToIm (unknown) –
Returns:

boolean

getDefaultImageMagickDir()

Retrieve the path to the directory containing ImageMagick’s convert utility. Th

Uses the ‘which’ command-line utility to detect the path to ‘convert’.Note that this will only work if the convert utility is in PHP’s PATH andthus can be located by ‘which’.

Returns:string The path to the directory if it can be found. Otherwise returns an empty string.
executeCommand($cmd, $status, $output, $errors)
Parameters:
  • $cmd (unknown) –
  • $status (unknown) –
  • $output (unknown) –
  • $errors (unknown) –