File indexing completed on 2025-01-26 05:29:13

0001 <?php
0002 
0003 namespace Intervention\Image\Commands;
0004 
0005 class ChecksumCommand extends AbstractCommand
0006 {
0007     /**
0008      * Calculates checksum of given image
0009      *
0010      * @param  \Intervention\Image\Image $image
0011      * @return boolean
0012      */
0013     public function execute($image)
0014     {
0015         $colors = [];
0016 
0017         $size = $image->getSize();
0018 
0019         for ($x=0; $x <= ($size->width-1); $x++) {
0020             for ($y=0; $y <= ($size->height-1); $y++) {
0021                 $colors[] = $image->pickColor($x, $y, 'array');
0022             }
0023         }
0024 
0025         $this->setOutput(md5(serialize($colors)));
0026 
0027         return true;
0028     }
0029 }