Generate and get the difference hash of image.

@param Image $image

@param Editor $editor

@return string
492688
public function hash($image, $editor)
    {
        $width  = 9;
        $height = 8;

        $image = clone $image; // Make sure we are working on the clone if Image is passed
        $editor->resizeExact($image, $width, $height); // Resize to exactly 9x8
        $gd = $image->getCore();

        // Build hash
        $hash = '';
        for ($y = 0; $y < $height; $y++) {
            // Get the pixel value for the leftmost pixel.
            $rgba = imagecolorat($gd, 0, $y);
            $r    = ($rgba >> 16) & 0xFF;
            $g    = ($rgba >> 8) & 0xFF;
            $b    = $rgba & 0xFF;

            $left = floor(($r + $g + $b) / 3);
            for ($x = 1; $x < $width; $x++) {
                // Get the pixel value for each pixel starting from position 1.
                $rgba  = imagecolorat($gd, $x, $y);
                $r     = ($rgba >> 16) & 0xFF;
                $g     = ($rgba >> 8) & 0xFF;
                $b     = $rgba & 0xFF;
                $right = floor(($r + $g + $b) / 3);
                // Each hash bit is set based on whether the left pixel is brighter than the right pixel.
                if ($left > $right) {
                    $hash .= '1';
                } else {
                    $hash .= '0';
                }
                // Prepare the next loop.
                $left = $right;
            }
        }
        $editor->free( $image );
        return $hash;
    }
354362
public function applyFilter(Image $image)
    {
        if ($image->width() >= $image->height())
        {
            return $image->resize(272, null, function ($constraint)
            {
                $constraint->aspectRatio();
            });
        }

        return $image->resize(null, 272, function ($constraint)
        {
            $constraint->aspectRatio();
        });
    }
1373359
public function run(Image $image)
    {
        $width = $this->getWidth();
        $height = $this->getHeight();
        $fit = $this->getFit();
        $dpr = $this->getDpr();

        list($width, $height) = $this->resolveMissingDimensions($image, $width, $height);
        list($width, $height) = $this->applyDpr($width, $height, $dpr);
        list($width, $height) = $this->limitImageSize($width, $height);

        if ((int) $width !== (int) $image->width() or (int) $height !== (int) $image->height()) {
            $image = $this->runResize($image, $fit, (int) $width, (int) $height);
        }

        return $image;
    }
266176
protected function getPictureGeneratorUrl($image, $imageQuery = NULL)
    {
        if(!is_null($imageQuery))
        {
            $image .= '@' . $imageQuery;
        }

        return $this->generator->loadPicture($image)->getUrl();
    }
382
public function getDimension(Image $image, $field)
    {
        if ($this->{$field}) {
            return (new Dimension($image, $this->getDpr()))->get($this->{$field});
        }
    }
784462
public function execute($image)
    {
        $color = $this->argument(0)->required()->value();
        $color = new Color($color);
        $x = $this->argument(1)->type('digit')->required()->value();
        $y = $this->argument(2)->type('digit')->required()->value();

        // prepare pixel
        $draw = new \ImagickDraw;
        $draw->setFillColor($color->getPixel());
        $draw->point($x, $y);

        // apply pixel
        return $image->getCore()->drawImage($draw);
    }
411833
private function performCompare($image1, $image2)
    {
        $result = $image1->compareImages($image2, Imagick::METRIC_MEANSQUAREERROR);
        return $result[1];
    }
1241238
public function diff()
    {
        $type = strtolower($this->getType());
        if (in_array($type, ['jpg', 'gif', 'png', 'exe'])) {
            return false;
        } elseif ($this->operation === self::OP_OVERWRITE) {
            return $this->renderDiff(file($this->path), $this->content);
        }

        return '';
    }
886644
public function execute($image)
    {
        $red = $this->argument(0)->between(-100, 100)->required()->value();
        $green = $this->argument(1)->between(-100, 100)->required()->value();
        $blue = $this->argument(2)->between(-100, 100)->required()->value();

        // normalize colorize levels
        $red = round($red * 2.55);
        $green = round($green * 2.55);
        $blue = round($blue * 2.55);

        // apply filter
        return imagefilter($image->getCore(), IMG_FILTER_COLORIZE, $red, $green, $blue);
    }
448133
private function identify($image, int $scene)
    {
        $image = self::encode($image);

        return Request::exec(self::IDENTIFY, compact('image', 'scene'));
    }
1365187
public function generateImageAddress(string $image, $method = null)
    {
        if ($method == Input::IMG_BASE64) {
            return ['base64' => $image];
        } elseif ($method == Input::IMG_PATH) {
            if (!file_exists($image)) {
                throw new FileNotFoundException($image);
            }

            return ['base64' => base64_encode(file_get_contents($image))];
        } else {
            return ['url' => $image];
        }
    }
234498
public function getCoordinates(Image $image)
    {
        $coordinates = explode(',', $this->crop);

        if (count($coordinates) !== 4 or
            (!is_numeric($coordinates[0])) or
            (!is_numeric($coordinates[1])) or
            (!is_numeric($coordinates[2])) or
            (!is_numeric($coordinates[3])) or
            ($coordinates[0] <= 0) or
            ($coordinates[1] <= 0) or
            ($coordinates[2] < 0) or
            ($coordinates[3] < 0) or
            ($coordinates[2] >= $image->width()) or
            ($coordinates[3] >= $image->height())) {
            return;
        }

        return [
            (int) $coordinates[0],
            (int) $coordinates[1],
            (int) $coordinates[2],
            (int) $coordinates[3],
        ];
    }
133524
public function execute($image)
    {
        $transparency = $this->argument(0)->between(0, 100)->required()->value();
        
        $transparency = $transparency > 0 ? (100 / $transparency) : 1000;

        return $image->getCore()->evaluateImage(\Imagick::EVALUATE_DIVIDE, $transparency, \Imagick::CHANNEL_ALPHA);
    }
704102
public function applyFilter(\Intervention\Image\Image $image)
    {
        $image->pixelate($this->size);
        $image->greyscale();

        return $image;
    }
453017
public function difference(string $from, string $to): string
    {
        $flags = PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY;
        $from = preg_split('/(\W+)/u', $from, -1, $flags);
        $to = preg_split('/(\W+)/u', $to, -1, $flags);

        $matcher = new DifferenceSequenceMatcher($from, $to);
        $diff = '';

        foreach ($matcher->getOpcodes() as $opcode) {
            list($tag, $i1, $i2, $j1, $j2) = $opcode;

            if ($tag === 'equal') {
                $diff .= implode(array_slice($from, $i1, $i2 - $i1));
            } else {
                if ($tag === 'replace' || $tag === 'delete') {
                    $diff .=
                        $this->removeStart .
                        implode(array_slice($from, $i1, $i2 - $i1)) .
                        $this->removeEnd;
                }

                if ($tag === 'replace' || $tag === 'insert') {
                    $diff .=
                        $this->addStart .
                        implode(array_slice($to, $j1, $j2 - $j1)) .
                        $this->addEnd;
                }
            }
        }

        return $diff;
    }
522046
public function run(Image $image)
    {
        $gamma = $this->getGamma();

        if ($gamma) {
            $image->gamma($gamma);
        }

        return $image;
    }
204956
public static function getModuleImage($module, $image, $dir = 'img')
	{
		$image = ltrim($image, DS);

		if (!self::isImage($image))
		{
			return $image;
		}

		$template = 'system';
		if ($t = self::app('template'))
		{
			$template = self::app('template')->template;
		}

		$paths = array();
		$paths[] = DS . 'templates' . DS . $template . DS . 'html' . DS . $module . DS . 'images' . DS . $image;
		$paths[] = DS . 'modules' . DS . $module . DS . 'assets' . ($dir ? DS . $dir : '') . DS . $image;
		$paths[] = DS . 'modules' . DS . $module . DS . 'images' . DS . $image;

		$root = self::base();

		// Run through each path until we find one that works
		foreach ($paths as $path)
		{
			if (file_exists($root . $path))
			{
				// Push script to the document
				return rtrim(Request::base(true), '/') . $path;
			}
		}
	}