EasyImages2.0/application/thumb.php

24 lines
792 B
PHP
Raw Normal View History

2021-10-30 09:19:15 +00:00
<?php
// +----------------------------------------------------------------------
// | 把大图缩略到缩略图指定的范围内,不留白(原图会剪切掉不符合比例的右边和下边)
// | https://www.php.cn/php-ask-458473.html
2022-01-12 18:48:08 +00:00
2021-10-30 09:19:15 +00:00
// +----------------------------------------------------------------------
require_once __DIR__ . '/function.php';
require_once __DIR__ . '/class.thumb.php';
$src = isset($_GET['img']) ? APP_ROOT . $_GET['img'] : APP_ROOT . '/public/images/404.png'; // 原图路径
2022-01-12 18:48:08 +00:00
if (!file_exists($src)) {
exit('image does not exist');
}
2022-01-27 09:25:46 +00:00
$w = isset($_GET['width']) ? $_GET['width'] : 258; // 预生成缩略图的宽
2022-01-12 18:48:08 +00:00
2022-01-27 09:25:46 +00:00
$h = isset($_GET['height']) ? $_GET['height'] : 258; // 预生成缩略图的高
2022-01-12 18:48:08 +00:00
Thumb::show($src, $w, $h);