BackupCommand.php 757 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace Intervention\Image\Gd\Commands;
  3. class BackupCommand extends \Intervention\Image\Commands\AbstractCommand
  4. {
  5. /**
  6. * Saves a backups of current state of image core
  7. *
  8. * @param \Intervention\Image\Image $image
  9. * @return boolean
  10. */
  11. public function execute($image)
  12. {
  13. $backupName = $this->argument(0)->value();
  14. // clone current image resource
  15. $size = $image->getSize();
  16. $clone = imagecreatetruecolor($size->width, $size->height);
  17. imagealphablending($clone, false);
  18. imagesavealpha($clone, true);
  19. imagecopy($clone, $image->getCore(), 0, 0, 0, 0, $size->width, $size->height);
  20. $image->setBackup($clone, $backupName);
  21. return true;
  22. }
  23. }