*prechod na novsiu verziu ZF
[sport-group.git] / library / Zend / Pdf / Resource / ImageFactory.php
blobc7e6b6488c3a64765f77723af0876851fdd46d41
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
16 * @package Zend_Pdf
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 $
23 /** Zend_Pdf */
24 require_once 'Zend/Pdf.php';
27 /**
28 * Zend_Pdf_ImageFactory
30 * Helps manage the diverse set of supported image file types.
32 * @package Zend_Pdf
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)) {
49 case 'tif':
50 //Fall through to next case;
51 case 'tiff':
52 return new Zend_Pdf_Resource_Image_Tiff($filename);
53 break;
54 case 'png':
55 return new Zend_Pdf_Resource_Image_Png($filename);
56 break;
57 case 'jpg':
58 //Fall through to next case;
59 case 'jpe':
60 //Fall through to next case;
61 case 'jpeg':
62 return new Zend_Pdf_Resource_Image_Jpeg($filename);
63 break;
64 default:
65 throw new Zend_Pdf_Exception("Cannot create image resource. File extension not known or unsupported type.");
66 break;