## Apache Zeta Components Manual :: File Source for handler.php

## Source for file handler.php

Documentation is available at handler.php

1. <?php
2. /**
3. * File containing the ezcImageAnalyzerHandler class.
4. *
5. * Licensed to the Apache Software Foundation (ASF) under one
6. * or more contributor license agreements. See the NOTICE file
7. * distributed with this work for additional information
8. * regarding copyright ownership. The ASF licenses this file
9. * to you under the Apache License, Version 2.0 (the
10. * "License"); you may not use this file except in compliance
11. * with the License. You may obtain a copy of the License at
12. *
13. * http://www.apache.org/licenses/LICENSE-2.0
14. *
15. * Unless required by applicable law or agreed to in writing,
16. * software distributed under the License is distributed on an
17. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18. * KIND, either express or implied. See the License for the
19. * specific language governing permissions and limitations
20. * under the License.
21. *
22. * @package ImageAnalysis
23. * @version //autogentag//
24. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
25. * @filesource
26. */
28. /**
29. * This base class has to be extended by all ezcImageAnalyzerHandler classes.
30. * An object of an ezcImageAnalyzerHandler class must implement this interface
31. * to work properly as a handler for ezcImageAnalyzer.
32. *
33. * @package ImageAnalysis
34. * @version //autogentag//
35. */
36. abstract class ezcImageAnalyzerHandler
37. {
38. /**
39. * Image is built with a palette and consists of indexed values per pixel.
40. */
41. const MODE_INDEXED = 1;
43. /**
44. * Image consists of RGB value per pixel.
45. */
46. const MODE_TRUECOLOR = 2;
48. /**
49. * No parts of image is transparent.
50. */
51. const TRANSPARENCY_OPAQUE = 1;
53. /*
54. * Selected palette entries are completely see-through.
55. */
56. const TRANSPARENCY_TRANSPARENT = 2;
58. /**
59. * Transparency determined pixel per pixel with a fuzzy value.
60. */
61. const TRANSPARENCY_TRANSLUCENT = 3;
63. /**
64. * Options for the handler.
65. *
66. * Usually this is empty, but some handlers need special options
67. * e.g. {@link ezcImageAnalyzerImagemagickHandler}.
68. *
69. * @var array(string=>mixed)
70. */
71. protected $options = array();
73. /**
74. * Create an ezcImageAnalyzerHandler to analyze a file.
75. *
76. * The constructor can optionally receive an array of options. Which
77. * options are utilized by the handler depends on it's implementation.
78. * To determine this, please refer to the specific handler.
79. *
80. * @throws ezcImageAnalyzerException
81. * If the handler is not able to work.
82. * @param array $options Possible options for the handler.
83. */
84. public function __construct ( array $options = array() )
85. {
86. $this-> options = $options;
87. }
89. /**
90. * Checks wether the given handler is available for analyzing images.
91. *
92. * Each ezcImageAnalyzerHandler must implement this method in order to
93. * check if the handler is available on the system. The method has to
94. * return true, if the handle is currently available to analyze images
95. * (e.g. if the GD extension is available, for the
96. * {@link ezcImageAnalyzerPhpHandler}).
97. *
98. * @return bool True if the handler is available.
99. */
100. abstract public function isAvailable ();
102. /**
103. * Analyzes the image type.
104. *
105. * This method analyzes image data to determine the MIME type. Each
106. * ezcImageAnalyzerHandler must at least be capable of performing this
107. * operation on a file. This method has to return the MIME type of the
108. * file to analyze in lowercase letters (e.g. "image/jpeg") or false, if
109. * the images MIME type could not be determined.
110. *
111. * @param string $file The file to analyze.
112. * @return string|boolThe MIME type if analyzation suceeded or false.
113. */
114. abstract public function analyzeType ( $file );
116. /**
117. * Analyze the image for detailed information.
118. *
119. * This may return various information about the image, depending on it's
120. * type and the implemented facilities of the handler. All information is
121. * collected in the struct {@link ezcImageAnalyzerData}. Which information
122. * is set about an image in the returned data struct, depends on the image
123. * type and the capabilities of the handler. At least the
124. * {@link ezcImageAnalyzerData::$mime} attribute must be set. Most handlers
125. * also provide additional information like the image dimensions and the size
126. * of the image file.
127. *
128. * @throws ezcImageAnalyzerFileNotProcessableException
129. * If image file can not be processed.
130. * @param string $file The file to analyze.
131. * @return ezcImageAnalyzerData
132. */
133. abstract public function analyzeImage ( $file );
135. /**
136. * Returns if the handler can analyze a given MIME type.
137. *
138. * This method returns if the driver is capable of analyzing a given MIME
139. * type. This method should be called before trying to actually analyze an
140. * image using the drivers {@link self::analyzeImage()} method.
141. *
142. * @param string $mime The MIME type to check for.
143. * @return bool True if the handler is able to analyze the MIME type.
144. */
145. abstract public function canAnalyze ( $mime );
146. }
147. ?>

Documentation generated by phpDocumentor 1.4.3