ChecksumCommand.php 614 B

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