3 namespace Drupal\imagemagick;
6 * Provides an interface for ImageMagick format mappers.
8 interface ImagemagickFormatMapperInterface {
11 * Validates the format map.
13 * The map is an associative array with ImageMagick image formats (e.g.
14 * JPEG, GIF87, etc.) as keys and an associative array of format variables
15 * as value. Each array element is structured like the following:
18 * 'mime_type' => 'image/tiff',
21 * 'exclude_extensions' => 'tif, tifx',
25 * The format variables are as follows:
26 * - 'mime_type': the MIME type of the image format. This is used to resolve
27 * the supported file extensions, e.g. ImageMagick 'JPEG' format is mapped
28 * to MIME type 'image/jpeg' which in turn will be mapped to 'jpeg jpg
29 * jpe' image file extensions.
30 * - 'enabled': (optional) defines if the fomat needs to be enabled within
31 * the toolkit. Defaults to TRUE.
32 * - 'weight': (optional) is used in cases where an image file extension is
33 * mapped to more than one ImageMagick format. It is needed in file format
34 * conversions, e.g. convert from 'png' to 'gif': shall 'GIF' or 'GIF87'
35 * internal Imagemagick format be used? The format will lower weight will
36 * be used. Defaults to 0.
37 * - 'exclude_extensions': (optional) is used to limit the file extensions
38 * to be supported by the toolkit, if the mapping MIME type <-> file
39 * extension returns more extensions than needed, and we do not want to
40 * alter the MIME type mapping.
43 * An associative array with formats as keys and an associative array
44 * of format variables as value.
47 * An array of arrays of error strings.
49 public function validateMap(array $map);
52 * Gets the list of currently enabled image formats.
55 * A simple array of image formats.
57 public function getEnabledFormats();
60 * Gets the list of currently enabled image file extensions.
63 * A simple array of image file extensions.
65 public function getEnabledExtensions();
68 * Checks if an image format is enabled in the toolkit.
70 * @param string $format
71 * An image format in ImageMagick's internal representation (e.g. JPEG,
75 * TRUE if the specified format is enabled within the toolkit, FALSE
78 public function isFormatEnabled($format);
81 * Gets the MIME type of an image format.
83 * @param string $format
84 * An image format in ImageMagick's internal representation (e.g. JPEG,
88 * The MIME type of the specified format if the format is enabled in the
89 * toolkit, NULL otherwise.
91 public function getMimeTypeFromFormat($format);
94 * Gets the image format, given the image file extension.
96 * @param string $extension
97 * An image file extension (e.g. jpeg, jpg, png, etc.), without leading
100 * @return string|null
101 * The ImageMagick internal format (e.g. JPEG, GIF87, etc.) of the
102 * specified extension, if the format is enabled in the toolkit. NULL
105 public function getFormatFromExtension($extension);