7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
17 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
18 * @license http://framework.zend.com/license/new-bsd New BSD License
19 * @version $Id: ImageFactory.php 16541 2009-07-07 06:59:03Z bkarwin $
24 require_once 'Zend/Pdf.php';
28 * Zend_Pdf_ImageFactory
30 * Helps manage the diverse set of supported image file types.
33 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
34 * @license http://framework.zend.com/license/new-bsd New BSD License
35 * @todo Use Zend_Mime not file extension for type determination.
37 class Zend_Pdf_Resource_ImageFactory
39 public static function factory($filename) {
40 if(!is_file($filename)) {
41 throw new Zend_Pdf_Exception("Cannot create image resource. File not found.");
43 $extension = pathinfo($filename, PATHINFO_EXTENSION
);
45 * There are plans to use Zend_Mime and not file extension. In the mean time, if you need to
46 * use an alternate file extension just spin up the right processor directly.
48 switch (strtolower($extension)) {
50 //Fall through to next case;
52 return new Zend_Pdf_Resource_Image_Tiff($filename);
55 return new Zend_Pdf_Resource_Image_Png($filename);
58 //Fall through to next case;
60 //Fall through to next case;
62 return new Zend_Pdf_Resource_Image_Jpeg($filename);
65 throw new Zend_Pdf_Exception("Cannot create image resource. File extension not known or unsupported type.");