Image.php 1.5KB

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