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;
 }
 public function copyDimensions(PhabricatorFile $file)
 {
     $metadata = $file->getMetadata();
     $width = idx($metadata, self::METADATA_IMAGE_WIDTH);
     if ($width) {
         $this->metadata[self::METADATA_IMAGE_WIDTH] = $width;
     }
     $height = idx($metadata, self::METADATA_IMAGE_HEIGHT);
     if ($height) {
         $this->metadata[self::METADATA_IMAGE_HEIGHT] = $height;
     }
     return $this;
 }