Просмотр файла vendor/intervention/image/src/Intervention/Image/Commands/ChecksumCommand.php

Размер файла: 609B
  1. <?php
  2.  
  3. namespace Intervention\Image\Commands;
  4.  
  5. class ChecksumCommand extends AbstractCommand
  6. {
  7. /**
  8. * Calculates checksum of given image
  9. *
  10. * @param \Intervention\Image\Image $image
  11. * @return boolean
  12. */
  13. public function execute($image)
  14. {
  15. $colors = [];
  16.  
  17. $size = $image->getSize();
  18.  
  19. for ($x=0; $x <= ($size->width-1); $x++) {
  20. for ($y=0; $y <= ($size->height-1); $y++) {
  21. $colors[] = $image->pickColor($x, $y, 'array');
  22. }
  23. }
  24.  
  25. $this->setOutput(md5(serialize($colors)));
  26.  
  27. return true;
  28. }
  29. }