(no comment)
This commit is contained in:
parent
9f6302fa48
commit
d3eb3720f7
17
router.php
17
router.php
|
@ -183,11 +183,11 @@ function p_img($src, $opts, $ext) {
|
|||
/* Given a source image and options, creates the appropriate images
|
||||
* jpeg, webp, and avif for lossy, and png and lossless webp for lossless
|
||||
*/
|
||||
function gen_images($src, $opts = "") {
|
||||
function gen_images($src, $opts = "", $lossy=0) {
|
||||
$psrc = ltrim($src, '/');
|
||||
$path = pathinfo($psrc);
|
||||
|
||||
if (in_array($path['extension'], ["jpg", "jpeg"])) {
|
||||
if ($lossy || in_array($path['extension'], ["jpg", "jpeg"])) {
|
||||
$je = ltrim(p_img($src, $opts, "jpg"), '/');
|
||||
|
||||
$jpath = pathinfo($je);
|
||||
|
@ -205,6 +205,8 @@ function gen_images($src, $opts = "") {
|
|||
if (!file_exists($ae)) {
|
||||
`convert -quality 80 $opts $psrc $ae`;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -216,17 +218,20 @@ function gen_images($src, $opts = "") {
|
|||
`mkdir -p $genp`;
|
||||
|
||||
if (!file_exists($we)) {
|
||||
`convert -quality 80 -define webp:lossless=true $psrc $we`;
|
||||
`convert -define webp:lossless=true $opts $psrc $we`;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function make_img($src, $opts="", $q=80) {
|
||||
/* If lossy is true, makes lossless images lossy; does nothing for already lossy images */
|
||||
function make_img($src, $opts="", $lossy=0) {
|
||||
$p = img_src($src);
|
||||
gen_images($p, $opts);
|
||||
gen_images($p, $opts, $lossy);
|
||||
|
||||
if (pathinfo($p)['extension'] == "png") {
|
||||
if (!$lossy && pathinfo($p)['extension'] == "png") {
|
||||
$pe = $p;
|
||||
$we = p_img($p, $opts, "webp");
|
||||
|
||||
|
|
Loading…
Reference in a new issue