Инструменты пользователя

Инструменты сайта


programming:php:image_resize_mb

Clever Image resize

$quality = 90;
while(filesize($full_path) > 1048576 && $quality > 20) {
    $img = imagecreatefromjpeg($full_path);
    imagejpeg($img,$full_path,$quality);

    $quality = $quality - 10;
    clearstatcache();
}
if(filesize($full_path) > 1048576) {echo "<p>File too large</p>"; unlink($full_path); exit;}
programming/php/image_resize_mb.txt · Последнее изменение: 2018/06/07 12:33 — artur

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki