3 namespace Drupal\imagemagick;
6 * Provides an interface for ImageMagick format mappers.
9 interface ImagemagickFormatMapperInterface {
12 * Validates the format map.
14 * The map is an associative array with ImageMagick image formats (e.g.
15 * JPEG, GIF87, etc.) as keys and an associative array of format variables
16 * as value. Each array element is structured like the following:
19 * 'mime_type' => 'image/tiff',
22 * 'exclude_extensions' => 'tif, tifx',
26 * The format variables are as follows:
27 * - 'mime_type': the MIME type of the image format. This is used to resolve
28 * the supported file extensions, e.g. ImageMagick 'JPEG' format is mapped
29 * to MIME type 'image/jpeg' which in turn will be mapped to 'jpeg jpg
30 * jpe' image file extensions.
31 * - 'enabled': (optional) defines if the fomat needs to be enabled within
32 * the toolkit. Defaults to TRUE.
33 * - 'weight': (optional) is used in cases where an image file extension is
34 * mapped to more than one ImageMagick format. It is needed in file format
35 * conversions, e.g. convert from 'png' to 'gif': shall 'GIF' or 'GIF87'
36 * internal Imagemagick format be used? The format will lower weight will
37 * be used. Defaults to 0.
38 * - 'exclude_extensions': (optional) is used to limit the file extensions
39 * to be supported by the toolkit, if the mapping MIME type <-> file
40 * extension returns more extensions than needed, and we do not want to
41 * alter the MIME type mapping.
44 * An associative array with formats as keys and an associative array
45 * of format variables as value.
48 * An array of arrays of error strings.
50 public function validateMap(array $map);
53 * Gets the list of currently enabled image formats.
56 * A simple array of image formats.
58 public function getEnabledFormats();
61 * Gets the list of currently enabled image file extensions.
64 * A simple array of image file extensions.
66 public function getEnabledExtensions();
69 * Checks if an image format is enabled in the toolkit.
71 * @param string $format
72 * An image format in ImageMagick's internal representation (e.g. JPEG,
76 * TRUE if the specified format is enabled within the toolkit, FALSE
79 public function isFormatEnabled($format);
82 * Gets the MIME type of an image format.
84 * @param string $format
85 * An image format in ImageMagick's internal representation (e.g. JPEG,
89 * The MIME type of the specified format if the format is enabled in the
90 * toolkit, NULL otherwise.
92 public function getMimeTypeFromFormat($format);
95 * Gets the image format, given the image file extension.
97 * @param string $extension
98 * An image file extension (e.g. jpeg, jpg, png, etc.), without leading
101 * @return string|null
102 * The ImageMagick internal format (e.g. JPEG, GIF87, etc.) of the
103 * specified extension, if the format is enabled in the toolkit. NULL
106 public function getFormatFromExtension($extension);