From d667cb23b08c5ebbbfd7d5b1870f719eb62573f6 Mon Sep 17 00:00:00 2001 From: satopian Date: Sun, 3 Nov 2024 18:21:31 +0900 Subject: [PATCH] thumbnail_gd.inc.php --- petitnote/thumbnail_gd.inc.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/petitnote/thumbnail_gd.inc.php b/petitnote/thumbnail_gd.inc.php index d309498d..8fb80f92 100644 --- a/petitnote/thumbnail_gd.inc.php +++ b/petitnote/thumbnail_gd.inc.php @@ -24,20 +24,20 @@ public static function thumb($path,$fname,$time,$max_w,$max_h,$options=[]){ $fsize = filesize($fname); // ファイルサイズを取得 list($w,$h) = GetImageSize($fname); // 画像の幅と高さを取得 - $w_h_size_over=$max_w && $max_h && ($w > $max_w || $h > $max_h); - $f_size_over=!isset($options['toolarge']) ? ($fsize>1024*1024) : false; + $w_h_size_over = $max_w && $max_h && ($w > $max_w || $h > $max_h); + $f_size_over = !isset($options['toolarge']) ? ($fsize>1024*1024) : false; if(!$w_h_size_over && !$f_size_over && !isset($options['webp']) && !isset($options['png2webp']) && !isset($options['png2jpeg'])){ return; } - if(isset($options['png2jpeg'])||isset($options['png2webp'])||!$max_w||!$max_h){//リサイズしない + if(!$w_h_size_over || isset($options['png2jpeg']) || isset($options['png2webp']) || !$max_w || !$max_h){//リサイズしない $out_w = $w; $out_h = $h; }else{// リサイズ $w_ratio = $max_w / $w; $h_ratio = $max_h / $h; $ratio = min($w_ratio, $h_ratio); - $out_w = $w_h_size_over ? ceil($w * $ratio):$w;//端数の切り上げ - $out_h = $w_h_size_over ? ceil($h * $ratio):$h; + $out_w = ceil($w * $ratio);//端数の切り上げ + $out_h = ceil($h * $ratio); } $mime_type = mime_content_type($fname);