mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-02-12 09:25:26 +00:00
Avoid upscaling small images
This commit is contained in:
parent
5fc83beb2c
commit
27b715cb35
1 changed files with 7 additions and 3 deletions
|
@ -72,6 +72,8 @@ class Image
|
||||||
return [
|
return [
|
||||||
'dimensions' => $this->orientations()[$orientation],
|
'dimensions' => $this->orientations()[$orientation],
|
||||||
'orientation' => $orientation,
|
'orientation' => $orientation,
|
||||||
|
'width_original' => $width,
|
||||||
|
'height_original' => $height,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,9 +159,11 @@ class Image
|
||||||
$media->metadata = json_encode($meta);
|
$media->metadata = json_encode($meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
$img->resize($aspect['width'], $aspect['height'], function ($constraint) {
|
if ( ($ratio['width_original'] > $aspect['width']) || ($ratio['height_original'] > $aspect['height']) ) {
|
||||||
$constraint->aspectRatio();
|
$img->resize($aspect['width'], $aspect['height'], function ($constraint) {
|
||||||
});
|
$constraint->aspectRatio();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$converted = $this->setBaseName($path, $thumbnail, $img->extension);
|
$converted = $this->setBaseName($path, $thumbnail, $img->extension);
|
||||||
$newPath = storage_path('app/'.$converted['path']);
|
$newPath = storage_path('app/'.$converted['path']);
|
||||||
|
|
Loading…
Reference in a new issue