Image.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. /**
  10. * An image, embedded in a multipart message.
  11. *
  12. * @author Chris Corbyn
  13. */
  14. class Swift_Image extends Swift_EmbeddedFile
  15. {
  16. /**
  17. * Create a new EmbeddedFile.
  18. *
  19. * Details may be optionally provided to the constructor.
  20. *
  21. * @param string|Swift_OutputByteStream $data
  22. * @param string $filename
  23. * @param string $contentType
  24. */
  25. public function __construct($data = null, $filename = null, $contentType = null)
  26. {
  27. parent::__construct($data, $filename, $contentType);
  28. }
  29. /**
  30. * Create a new Image.
  31. *
  32. * @param string|Swift_OutputByteStream $data
  33. * @param string $filename
  34. * @param string $contentType
  35. *
  36. * @return Swift_Image
  37. */
  38. public static function newInstance($data = null, $filename = null, $contentType = null)
  39. {
  40. return new self($data, $filename, $contentType);
  41. }
  42. /**
  43. * Create a new Image from a filesystem path.
  44. *
  45. * @param string $path
  46. *
  47. * @return Swift_Image
  48. */
  49. public static function fromPath($path)
  50. {
  51. $image = self::newInstance()->setFile(
  52. new Swift_ByteStream_FileByteStream($path)
  53. );
  54. return $image;
  55. }
  56. }