diff --git a/src/applications/files/PhabricatorImageTransformer.php b/src/applications/files/PhabricatorImageTransformer.php index f29ce97835..71f07a231e 100644 --- a/src/applications/files/PhabricatorImageTransformer.php +++ b/src/applications/files/PhabricatorImageTransformer.php @@ -20,81 +20,6 @@ final class PhabricatorImageTransformer extends Phobject { )); } - public function executeConpherenceTransform( - PhabricatorFile $file, - $top, - $left, - $width, - $height) { - - $image = $this->crasslyCropTo( - $file, - $top, - $left, - $width, - $height); - - return PhabricatorFile::newFromFileData( - $image, - array( - 'name' => 'conpherence-'.$file->getName(), - 'profile' => true, - 'canCDN' => true, - )); - } - - private function crasslyCropTo(PhabricatorFile $file, $top, $left, $w, $h) { - $data = $file->loadFileData(); - $src = imagecreatefromstring($data); - $dst = $this->getBlankDestinationFile($w, $h); - - $scale = self::getScaleForCrop($file, $w, $h); - $orig_x = $left / $scale; - $orig_y = $top / $scale; - $orig_w = $w / $scale; - $orig_h = $h / $scale; - - imagecopyresampled( - $dst, - $src, - 0, 0, - $orig_x, $orig_y, - $w, $h, - $orig_w, $orig_h); - - return self::saveImageDataInAnyFormat($dst, $file->getMimeType()); - } - - private function getBlankDestinationFile($dx, $dy) { - $dst = imagecreatetruecolor($dx, $dy); - imagesavealpha($dst, true); - imagefill($dst, 0, 0, imagecolorallocatealpha($dst, 255, 255, 255, 127)); - - return $dst; - } - - public static function getScaleForCrop( - PhabricatorFile $file, - $des_width, - $des_height) { - - $metadata = $file->getMetadata(); - $width = $metadata[PhabricatorFile::METADATA_IMAGE_WIDTH]; - $height = $metadata[PhabricatorFile::METADATA_IMAGE_HEIGHT]; - - if ($height < $des_height) { - $scale = $height / $des_height; - } else if ($width < $des_width) { - $scale = $width / $des_width; - } else { - $scale_x = $des_width / $width; - $scale_y = $des_height / $height; - $scale = max($scale_x, $scale_y); - } - - return $scale; - } - private function applyMemeToFile( PhabricatorFile $file, $upper_text,