You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.6 KiB

11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  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.
  14. *
  15. * @category Zend
  16. * @package Zend_Pdf
  17. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id$
  20. */
  21. /**
  22. * Zend_Pdf_ImageFactory
  23. *
  24. * Helps manage the diverse set of supported image file types.
  25. *
  26. * @package Zend_Pdf
  27. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  28. * @license http://framework.zend.com/license/new-bsd New BSD License
  29. * @todo Use Zend_Mime not file extension for type determination.
  30. */
  31. class Zend_Pdf_Resource_ImageFactory
  32. {
  33. public static function factory($filename) {
  34. if(!is_file($filename)) {
  35. // require_once 'Zend/Pdf/Exception.php';
  36. throw new Zend_Pdf_Exception("Cannot create image resource. File not found.");
  37. }
  38. $extension = pathinfo($filename, PATHINFO_EXTENSION);
  39. /*
  40. * There are plans to use Zend_Mime and not file extension. In the mean time, if you need to
  41. * use an alternate file extension just spin up the right processor directly.
  42. */
  43. switch (strtolower($extension)) {
  44. case 'tif':
  45. //Fall through to next case;
  46. case 'tiff':
  47. // require_once 'Zend/Pdf/Resource/Image/Tiff.php';
  48. return new Zend_Pdf_Resource_Image_Tiff($filename);
  49. break;
  50. case 'png':
  51. // require_once 'Zend/Pdf/Resource/Image/Png.php';
  52. return new Zend_Pdf_Resource_Image_Png($filename);
  53. break;
  54. case 'jpg':
  55. //Fall through to next case;
  56. case 'jpe':
  57. //Fall through to next case;
  58. case 'jpeg':
  59. // require_once 'Zend/Pdf/Resource/Image/Jpeg.php';
  60. return new Zend_Pdf_Resource_Image_Jpeg($filename);
  61. break;
  62. default:
  63. // require_once 'Zend/Pdf/Exception.php';
  64. throw new Zend_Pdf_Exception("Cannot create image resource. File extension not known or unsupported type.");
  65. break;
  66. }
  67. }
  68. }