/framework/vendor/swift/lib/classes/Swift/Image.php

http://zoop.googlecode.com/ · PHP · 62 lines · 21 code · 7 blank · 34 comment · 0 complexity · 8732e3a328389f53302fe889d1b61e2a MD5 · raw file

  1. <?php
  2. /*
  3. * This file is part of SwiftMailer.
  4. * (c) 2004-2009 Chris Corbyn
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. //@require 'Swift/Image.php';
  10. //@require 'Swift/ByteStream/FileByteStream.php';
  11. /**
  12. * An image, embedded in a multipart message.
  13. * @package Swift
  14. * @subpackage Mime
  15. * @author Chris Corbyn
  16. */
  17. class Swift_Image extends Swift_EmbeddedFile
  18. {
  19. /**
  20. * Create a new EmbeddedFile.
  21. * Details may be optionally provided to the constructor.
  22. * @param string|Swift_OutputByteStream $data
  23. * @param string $filename
  24. * @param string $contentType
  25. */
  26. public function __construct($data = null, $filename = null,
  27. $contentType = null)
  28. {
  29. parent::__construct($data, $filename, $contentType);
  30. }
  31. /**
  32. * Create a new Image.
  33. * @param string|Swift_OutputByteStream $data
  34. * @param string $filename
  35. * @param string $contentType
  36. * @return Swift_Mime_EmbeddedFile
  37. */
  38. public static function newInstance($data = null, $filename = null,
  39. $contentType = null)
  40. {
  41. return new self($data, $filename, $contentType);
  42. }
  43. /**
  44. * Create a new Image from a filesystem path.
  45. * @param string $path
  46. * @return Swift_Mime_EmbeddedFile
  47. */
  48. public static function fromPath($path)
  49. {
  50. $image = self::newInstance()->setFile(
  51. new Swift_ByteStream_FileByteStream($path)
  52. );
  53. return $image;
  54. }
  55. }