Gets a hash.

@param string $version
@param array $image
@return string|null
354598
protected function _getHash($version, $image) {
		if (!empty($version)) {
			$hash = Configure::read('FileStorage.imageHashes.' . $image['model'] . '.' . $version);
			if (empty($hash)) {
				throw new InvalidArgumentException(sprintf('No valid version key (Identifier: `%s` Key: `%s`) passed!', @$image['model'], $version));
			}

			return $hash;
		}

		return null;
	}
1325118
private function resolveVersion($version)
    {
        if (isset($this->aliases[$version])) {
            $version = $this->aliases[$version];

            return $version;
        }

        return $version;
    }
1097915
public function getTemplateWebPath($file = '',$version = true) {
		$webPath = '/assets/';

		if(!empty($file) && $version) {
			$webPath .= $file.'?'.$this->get_static_version();
		}else{
			$webPath .= $file;
		}

		return $webPath;
	}
247977
public function asset($asset, $version = null)
    {
        $host = $this->request->getHost();
        $port = $this->request->getPort();
        $path = $this->request->getBasePath();

        if ('/' !== substr($asset, 1)) {
            $asset = '/'.$asset;
        }

        if (80 === $port) {
            $port = '';
        } else {
            $port = ':'.$port;
        }

        return '//'.$host.$port.$path.$asset;
    }
858294
protected function getPackageKeyFromMigrationVersion(Version $version)
    {
        $sortedAvailablePackages = $this->packageManager->getAvailablePackages();
        usort($sortedAvailablePackages, function (PackageInterface $packageOne, PackageInterface $packageTwo) {
            return strlen($packageTwo->getPackagePath()) - strlen($packageOne->getPackagePath());
        });

        $reflectedClass = new \ReflectionClass($version->getMigration());
        $classPathAndFilename = Files::getUnixStylePath($reflectedClass->getFileName());

        /** @var $package PackageInterface */
        foreach ($sortedAvailablePackages as $package) {
            $packagePath = Files::getUnixStylePath($package->getPackagePath());
            if (strpos($classPathAndFilename, $packagePath) === 0) {
                return $package->getPackageKey();
            }
        }

        return '';
    }
147890
public function getSiteHomePageObject($version = 'RECENT')
    {
        $tree = $this->getSiteTreeObject();

        return $tree === null ? null : $tree->getSiteHomePageObject($version);
    }
254138
protected function getFileVersion($id, $version)
    {
        /** @var MediaInterface $mediaEntity */
        $mediaEntity = $this->container->get('sulu.repository.media')->findMediaById($id);

        if (!$mediaEntity) {
            return null;
        }

        $file = $mediaEntity->getFiles()[0];

        if (!$file) {
            return null;
        }

        if (!$version) {
            $version = $mediaEntity->getFiles()[0]->getVersion();
        }

        $fileVersion = $file->getFileVersion((int) $version);

        if (!$fileVersion) {
            throw new FileVersionNotFoundException($id, $version);
        }

        return $fileVersion;
    }
1159723
public function getAssetContent($type, $hash, $version)
    {
        if (!$this->isCached($type, $hash, $version)) {
            return '';
        }
        
        $targetFile = $this->buildFilePath($type, $hash, $version);
        return $this->fileBackend->loadFromFile($targetFile);
    }
1356358
public function getHashMaybeUpload(AbstractLocalImage $image)
    {
        if ($hash = $image->getRokkaHash()) {
            return $hash;
        }
        if (!$hash = $this->callbacks->getHash($image)) {
            if (!$this->isImage($image)) {
                return null;
            }
            $sourceImage = $this->imageUpload($image);
            if (null !== $sourceImage) {
                $hash = $this->callbacks->saveHash($image, $sourceImage);
            }
        }

        return $hash;
    }
732884
public function make(Image $image, string $version): Image
    {
        $config = $this->getVersionConfig($version);
        $manipulator = $this->extractManipulatorNameFromConfig($config);

        $binary = $this->manipulate($image->getBinary(), $manipulator, $config);

        return $image->modify($binary, $version);
    }
656162
protected function getVersionUrl(Version $version) : string
    {
        if (count($this->versionUrls) === 0) {
            $this->fetchSupportedVersions();
        }

        if (!array_key_exists($version->getAndroidVersion(), $this->versionUrls)) {
            throw new UnsupportedVersionException($version);
        }

        return $this->versionUrls[$version->getAndroidVersion()];
    }
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;
    }
1126155
public function getFormat(Image $image)
    {
        $allowed = [
            'gif' => 'image/gif',
            'jpg' => 'image/jpeg',
            'pjpg' => 'image/jpeg',
            'png' => 'image/png',
            'webp' => 'image/webp',
        ];

        if (array_key_exists($this->fm, $allowed)) {
            return $this->fm;
        }

        if ($format = array_search($image->mime(), $allowed, true)) {
            return $format;
        }

        return 'jpg';
    }
37977
def get_image_hashes(image_path, version=None, levels=None):
    '''
    '''
    if levels is None:
        levels = get_levels(version=version)
    hashes = dict()
    for level_name,level_filter in levels.items():
        hashes[level_name] = get_image_hash(image_path,
                                            level_filter=level_filter)
    return hashes
326582
public function getHash($fileName)
    {
        if (array_key_exists($fileName, $this->data)) {
            return $this->data[$fileName];
        } else if (array_key_exists($this->_makeRelative($fileName), $this->data)) {
            return $this->data[$this->_makeRelative($fileName)];
        } else {
            return null;
        }
    }
373547
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
        $imagick = $image->getCore();

        // Build hash
        $hash = '';
        for ($y = 0; $y < $height; $y++) {
            // Get the pixel value for the leftmost pixel.
            $rgba = $imagick->getImagePixelColor(0, $y)->getColor();

            $left = floor(($rgba['r'] + $rgba['g'] + $rgba['b']) / 3);
            for ($x = 1; $x < $width; $x++) {
                // Get the pixel value for each pixel starting from position 1.
                $rgba  = $imagick->getImagePixelColor($x, $y)->getColor();
                $right = floor(($rgba['r'] + $rgba['g'] + $rgba['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;
    }
83343
public function get($key)
	{
		$hash = md5($key);
		$cacheFile = $this->getPath().'/'.$hash.'.cache';

		if (!is_file($cacheFile)) {
			return null;
		}
		return unserialize(file_get_contents($cacheFile));
	}