pull/18/head
icret 2022-01-03 06:47:28 +08:00
parent 8b664370d5
commit 22c6df735b
4 changed files with 32 additions and 19 deletions

View File

@ -274,12 +274,12 @@ if (isset($_POST['radio'])) {
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label>上传前改变图片尺寸->更改后的宽度:</label><label id="image_x"><?php echo $config['image_x']; ?></label><label>像素</label> <label>图片裁剪的宽度(设置0则不生效)->更改后的宽度:</label><label id="image_x"><?php echo $config['image_x']; ?></label><label>像素</label>
<input type="range" class="form-control" name="image_x" value="<?php echo $config['image_x']; ?>" min="100" max="10240" step="100" onchange="document.getElementById('image_x').innerHTML=value"> <input type="range" class="form-control" name="image_x" value="<?php echo $config['image_x']; ?>" min="0" max="10240" step="100" onchange="document.getElementById('image_x').innerHTML=value">
</div> </div>
<div class="form-group"> <div class="form-group">
<label>上传前改变图片尺寸->更改后的高度:</label><label id="image_y"><?php echo $config['image_y']; ?></label><label>像素</label> <label>图片裁剪的高度(设置0则不生效)->更改后的高度:</label><label id="image_y"><?php echo $config['image_y']; ?></label><label>像素</label>
<input type="range" class="form-control" name="image_y" value="<?php echo $config['image_y']; ?>" min="100" max="10240" step="100" onchange="document.getElementById('image_y').innerHTML=value"> <input type="range" class="form-control" name="image_y" value="<?php echo $config['image_y']; ?>" min="0" max="10240" step="100" onchange="document.getElementById('image_y').innerHTML=value">
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="switch"> <div class="switch">
@ -292,11 +292,11 @@ if (isset($_POST['radio'])) {
<div class="switch"> <div class="switch">
<input type="hidden" name="imgRatio_preserve_headers" value="0"> <input type="hidden" name="imgRatio_preserve_headers" value="0">
<input type="checkbox" name="imgRatio_preserve_headers" value="1" <?php if ($config['imgRatio_preserve_headers']) {echo 'checked="checked"';} ?>> <input type="checkbox" name="imgRatio_preserve_headers" value="1" <?php if ($config['imgRatio_preserve_headers']) {echo 'checked="checked"';} ?>>
<label style="font-weight: bold">压缩后是否保留图片原始数据</label> <label style="font-weight: bold">开启保留图片原始数据</label>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label>上传前图片压缩率控制(仅支持JPG)->更改后的压缩率:</label><label id="imgRatio_quality"><?php echo $config['imgRatio_quality']; ?></label><label>%</label> <label>上传前压缩图片(仅支持JPG)->更改后的压缩率:</label><label id="imgRatio_quality"><?php echo $config['imgRatio_quality']; ?></label><label>%</label>
<input type="range" class="form-control" name="imgRatio_quality" value="<?php echo $config['imgRatio_quality']; ?>" min="10" max="100" step="5" onchange="document.getElementById('imgRatio_quality').innerHTML=value"> <input type="range" class="form-control" name="imgRatio_quality" value="<?php echo $config['imgRatio_quality']; ?>" min="10" max="100" step="5" onchange="document.getElementById('imgRatio_quality').innerHTML=value">
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -113,7 +113,7 @@ function imgName()
return sha1(microtime()); return sha1(microtime());
break; break;
default: default:
return base_convert(date('His') . mt_rand(1024, 10240), 10, 36); // 将上传时间+随机数转换为36进制 例vx77yu return base_convert(date('His') . mt_rand(1024, 9999), 10, 36); // 将上传时间+随机数转换为36进制 例vx77yu
} }
} }
@ -417,7 +417,7 @@ function imgRatio()
{ {
global $config; global $config;
if ($config['imgRatio']) { if ($config['imgRatio']) {
echo $config['imgRatio'];
if ($config['imgRatio_crop'] === 1) { if ($config['imgRatio_crop'] === 1) {
$imgRatio_crop = 'true'; $imgRatio_crop = 'true';
} else { } else {
@ -430,10 +430,22 @@ echo $config['imgRatio'];
$imgRatio_preserve_headers = 'false'; $imgRatio_preserve_headers = 'false';
} }
if ($config['image_x'] != 0) {
$image_x = "width:" . $config['image_x'];
} else {
$image_x = null;
}
if ($config['image_y'] != 0) {
$image_y = "height:" . $config['image_y'];
} else {
$image_y = null;
}
return ' return '
resize:{ resize:{
width: ' . $config['image_x'] . ', ' . $image_x . ',
height: ' . $config['image_y'] . ', ' . $image_y . ',
crop: ' . $imgRatio_crop . ', crop: ' . $imgRatio_crop . ',
quality:' . $config['imgRatio_quality'] . ', quality:' . $config['imgRatio_quality'] . ',
preserve_headers: ' . $imgRatio_preserve_headers . ', preserve_headers: ' . $imgRatio_preserve_headers . ',
@ -662,12 +674,13 @@ function writefile($filename, $writetext, $openmod = 'w')
} }
} }
function get_online_thumbnail($imgUrl){ function get_online_thumbnail($imgUrl)
{
global $config; global $config;
if($config['thumbnail']){ if ($config['thumbnail']) {
$imgUrl = str_replace($config['imgurl'], '', $imgUrl); $imgUrl = str_replace($config['imgurl'], '', $imgUrl);
return $config['domain'].'/application/thumb.php?img='.$imgUrl.'&width=300&height=300'; return $config['domain'] . '/application/thumb.php?img=' . $imgUrl . '&width=300&height=300';
}else{ } else {
return $imgUrl; return $imgUrl;
} }
} }

View File

@ -30,10 +30,10 @@ $config=Array
'minWidth'=>5, 'minWidth'=>5,
'minHeight'=>5, 'minHeight'=>5,
'imgRatio'=>0, 'imgRatio'=>0,
'image_x'=>800, 'image_x'=>2500,
'image_y'=>800, 'image_y'=>2700,
'imgRatio_quality'=>60, 'imgRatio_quality'=>80,
'imgRatio_crop'=>1, 'imgRatio_crop'=>0,
'imgRatio_preserve_headers'=>1, 'imgRatio_preserve_headers'=>1,
'static_cdn'=>0, 'static_cdn'=>0,
'static_cdn_url'=>'https://cdn.jsdelivr.net/gh/icret/EasyImages2.0', 'static_cdn_url'=>'https://cdn.jsdelivr.net/gh/icret/EasyImages2.0',

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB