/** * Calculate a perceptual hash of an image string. * * @param mixed $data Image data * @return string */ public function hashFromString($data) { $resource = $this->createResource($data); $hash = $this->implementation->hash($resource); $this->destroyResource($resource); return $this->formatHash($hash); }
/** * Calculate a perceptual hash of an image. * * @param mixed $resource * @param integer $size * @return integer */ public function hash($resource) { $destroy = false; if (!is_resource($resource)) { $resource = $this->loadImageResource($resource); $destroy = true; } $hash = $this->implementation->hash($resource); if ($destroy) { imagedestroy($resource); } return $hash; }