Further modules included.
[yaffs-website] / web / modules / contrib / imagemagick / src / ImagemagickFormatMapperInterface.php
1 <?php
2
3 namespace Drupal\imagemagick;
4
5 /**
6  * Provides an interface for ImageMagick format mappers.
7  * )
8  */
9 interface ImagemagickFormatMapperInterface {
10
11   /**
12    * Validates the format map.
13    *
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:
17    * @code
18    *   'TIFF' => [
19    *     'mime_type' => 'image/tiff',
20    *     'enabled' => true,
21    *     'weight' => 10,
22    *     'exclude_extensions' => 'tif, tifx',
23    *   ],
24    * @endcode
25    *
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.
42    *
43    * @param array[] $map
44    *   An associative array with formats as keys and an associative array
45    *   of format variables as value.
46    *
47    * @return array[][]
48    *   An array of arrays of error strings.
49    */
50   public function validateMap(array $map);
51
52   /**
53    * Gets the list of currently enabled image formats.
54    *
55    * @return array
56    *   A simple array of image formats.
57    */
58   public function getEnabledFormats();
59
60   /**
61    * Gets the list of currently enabled image file extensions.
62    *
63    * @return array
64    *   A simple array of image file extensions.
65    */
66   public function getEnabledExtensions();
67
68   /**
69    * Checks if an image format is enabled in the toolkit.
70    *
71    * @param string $format
72    *   An image format in ImageMagick's internal representation (e.g. JPEG,
73    *   GIF87, etc.).
74    *
75    * @return bool
76    *   TRUE if the specified format is enabled within the toolkit, FALSE
77    *   otherwise.
78    */
79   public function isFormatEnabled($format);
80
81   /**
82    * Gets the MIME type of an image format.
83    *
84    * @param string $format
85    *   An image format in ImageMagick's internal representation (e.g. JPEG,
86    *   GIF87, etc.).
87    *
88    * @return string|null
89    *   The MIME type of the specified format if the format is enabled in the
90    *   toolkit, NULL otherwise.
91    */
92   public function getMimeTypeFromFormat($format);
93
94   /**
95    * Gets the image format, given the image file extension.
96    *
97    * @param string $extension
98    *   An image file extension (e.g. jpeg, jpg, png, etc.), without leading
99    *   dot.
100    *
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
104    *   otherwise.
105    */
106   public function getFormatFromExtension($extension);
107
108 }