Skip to content

Commit

Permalink
v6.11.2
Browse files Browse the repository at this point in the history
  • Loading branch information
satopian committed Oct 29, 2023
1 parent 3e0cb00 commit 8785ab4
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 16 deletions.
5 changes: 4 additions & 1 deletion potiboard5/potiboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,10 @@ function form($resno="",$tmp=""){
if(!USE_IMG_UPLOAD){//画像アップロード機能を使わない時
$dat['upfile'] = false;
} else{
if((!$resno && !$tmp) || (RES_UPLOAD && !$tmp)) $dat['upfile'] = true;
if((!$resno && !$tmp) || (RES_UPLOAD && !$tmp)){
$dat['upfile'] = true;
}

}
$dat['maxkb'] = MAX_KB;//実際にアップロードできるファイルサイズ
$dat['maxw'] = $resno ? MAX_RESW : MAX_W;
Expand Down
8 changes: 4 additions & 4 deletions potiboard5/templates/mono_en/mono_main.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ function add_to_com() {

@endif

<div class="epost">
@if ($notres and (!$diary or $addinfo))
<div class="epost">
@if ($notres and (!$diary or $addinfo))
<ul>
@if ($paint2 and !$diary)
<li>Canvas size is width {{$pminw}}px to {{$pmaxw}}px, height {{$pminh}}px to {{$pmaxh}}px.</li>
Expand All @@ -121,7 +121,7 @@ function add_to_com() {
</ul>
@endif
</div>
@endif
@endif
@if($form)
<div>
<form action="{{$self}}" method="post" enctype="multipart/form-data" id="comment_form">
Expand Down Expand Up @@ -179,7 +179,7 @@ function add_to_com() {
<li>Attachable files type: GIF, JPG, PNG and WEBP. </li>
<li>Attached image larger than width {{$maxw_px}}px height {{$maxh_px}}px will be reduced size.</li>
@endif
@if($paint or $upfile)
@if(($paintform and $paint) or $upfile)
<li>Images larger than width {{$maxw}}px height {{$maxh}}px will be will be thumbnailed.</li>
<li>The maximum amount of posted data is {{$maxkb}}KB. With sage function.</li>
@endif
Expand Down
1 change: 1 addition & 0 deletions potiboard5/templates/mono_en/mono_other.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
.pchup_button {
margin: 0 0 10px 0;
}
</style>
<title>{{$title}}</title>
<style id="for_mobile"></style>
Expand Down
69 changes: 58 additions & 11 deletions potiboard5/thumbnail_gd.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
//220729 処理が成功した時の返り値をtrueに変更。
//220321 透明な箇所が黒くなる問題に対応。透明部分を白に変換。
//201218 webp形式対応
$thumbnail_gd_ver=20221021;
$thumbnail_gd_ver=20231028;
defined('PERMISSION_FOR_DEST') or define('PERMISSION_FOR_DEST', 0606); //config.phpで未定義なら0606

function thumb($path,$time,$ext,$max_w,$max_h){
function thumb($path,$time,$ext,$max_w,$max_h,$options=[]){
$time=basename($time);
$fname=basename($path).'/'.$time.basename($ext);
if(!is_file($fname)){
Expand All @@ -31,7 +31,7 @@ function thumb($path,$time,$ext,$max_w,$max_h){
$out_w = $w_h_size_over ? ceil($w * $ratio):$w;//端数の切り上げ
$out_h = $w_h_size_over ? ceil($h * $ratio):$h;

switch (mime_content_type($fname)) {
switch ($mime_type = mime_content_type($fname)) {
case "image/gif";
if(!function_exists("ImageCreateFromGIF")){//gif
return;
Expand Down Expand Up @@ -65,27 +65,74 @@ function thumb($path,$time,$ext,$max_w,$max_h){
$exists_ImageCopyResampled = false;
if(function_exists("ImageCreateTrueColor")&&get_gd_ver()=="2"){
$im_out = ImageCreateTrueColor($out_w, $out_h);
if(function_exists("ImageColorAlLocate") && function_exists("imagefill")){
$background = ImageColorAlLocate($im_out, 0xFF, 0xFF, 0xFF);//背景色を白に
imagefill($im_out, 0, 0, $background);
}
if((isset($options['toolarge'])||isset($options['webp'])) && in_array($mime_type,["image/png","image/gif","image/webp"])){//透明度がある
if(function_exists("imagealphablending") && function_exists("imagesavealpha")){
imagealphablending($im_out, false);
imagesavealpha($im_out, true);//透明
}
}else{//透明度が無い
if(function_exists("ImageColorAlLocate") && function_exists("imagefill")){
$background = ImageColorAlLocate($im_out, 0xFF, 0xFF, 0xFF);//背景色が透明の時は白で塗りつぶす
imagefill($im_out, 0, 0, $background);
}
}
// コピー&再サンプリング&縮小
if(function_exists("ImageCopyResampled")&&RE_SAMPLED){
ImageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $out_w, $out_h, $w, $h);
$exists_ImageCopyResampled = true;
}
}else{$im_out = ImageCreate($out_w, $out_h);$nottrue = 1;}
}else{
$im_out = ImageCreate($out_w, $out_h);
}
// コピー&縮小
if(!$exists_ImageCopyResampled) ImageCopyResized($im_out, $im_in, 0, 0, 0, 0, $out_w, $out_h, $w, $h);
if(isset($options['toolarge'])){
$outfile=$fname;
//本体画像を縮小
switch ($mime_type) {
case "image/gif";
if(function_exists("ImagePNG")){
ImagePNG($im_out, $outfile,3);
}else{
ImageJPEG($im_out, $outfile,98);
}
break;
case "image/jpeg";
ImageJPEG($im_out, $outfile,98);
break;
case "image/png";
if(function_exists("ImagePNG")){
ImagePNG($im_out, $outfile,3);
}else{
ImageJPEG($im_out, $outfile,98);
}
break;
case "image/webp";
if(function_exists("ImageWEBP")&&version_compare(PHP_VERSION, '7.0.0', '>=')){
ImageWEBP($im_out, $outfile,98);
}else{
ImageJPEG($im_out, $outfile,98);
}
break;

default : return;
}

}elseif(isset($options['webp'])){
$outfile='webp/'.$time.'t.webp';
ImageWEBP($im_out, $outfile,90);

}else{
$outfile=THUMB_DIR.basename($time).'s.jpg';
// サムネイル画像を保存
$outfile=THUMB_DIR.basename($time).'s.jpg';
ImageJPEG($im_out, $outfile,THUMB_Q);
ImageJPEG($im_out, $outfile,THUMB_Q);
}
// 作成したイメージを破棄
ImageDestroy($im_in);
ImageDestroy($im_out);
if(!chmod($outfile,PERMISSION_FOR_DEST)){
return;
}
}

return is_file($outfile);

Expand Down

0 comments on commit 8785ab4

Please sign in to comment.