mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-26 15:30:58 +01:00
Remove some old image transform code with no callsites
Summary: Ref T13101. Ref T5258. This old image transform code no longer has callsites. Test Plan: Grepped for removed methods, no hits. Maniphest Tasks: T13101, T5258 Differential Revision: https://secure.phabricator.com/D19198
This commit is contained in:
parent
fc1ee20efe
commit
a099a06265
1 changed files with 0 additions and 75 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue