Skip to content

Commit

Permalink
Allow customizing the JPEG quality
Browse files Browse the repository at this point in the history
  • Loading branch information
markspolakovs committed May 17, 2020
1 parent 06199fd commit b48de30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Classes/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,12 @@ final class Config
* The formats to resize uploaded images to.
*
* The keys of the array are format names to rename to. The values are [x,y] sizes in pixels.
* If provided, the third value in the array is the JPEG quality. If none given, defaults to 80.
* @var int[][]
*/
public static $image_resize_formats = [
'podcast_small' => [1400, 1400],
'web' => [800, 800]
'web' => [800, 800, 90]
];

public static $default_image_format = 'web';
Expand Down
5 changes: 4 additions & 1 deletion src/Classes/ServiceAPI/MyRadio_Show.php
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,10 @@ public function setShowPhoto($tmp_path)
foreach (Config::$image_resize_formats as $name => $size) {
$resized = ImageUtils::cropAndResizeImage($img, $size[0], $size[1]);
$resizedPath = str_replace('.orig.', ".$name.", $path);
imagejpeg($resized, $resizedPath, 80);
imagejpeg(
$resized,
$resizedPath,
$size[2] ?? 80);
}

self::$db->query(
Expand Down

0 comments on commit b48de30

Please sign in to comment.