я был там, но не пойму что именно качать и как настраивать
А как установить его? чтобы можно было пользоваться ней из php как показано в примере на php.net:
$compressed_png_content = compress_png($read_from_path);
file_put_contents($save_to_path, $compressed_png_content);
Про использование, я имею ввиду, чтобы функция compress_png() была доступна в скрипте, достаточно запустить pngquant.exe? или что-то нужно подключать в php.ini или еще где-то...Там в архиве обычный .exe вроде.
Про использование вопрос не понял – на php.net точно такой же пример, как и на сайте разработчиков. Прям так же и использовать.
Мёд-пиво пил.я был там
function compress_png($path_to_png_file, $max_quality = 90)
{
if (!file_exists($path_to_png_file)) {
throw new Exception("File does not exist: $path_to_png_file");
}
$min_quality = 60;
$compressed_png_content = shell_exec("pngquant --quality=$min_quality-$max_quality - < ".escapeshellarg($path_to_png_file));
if (!$compressed_png_content) {
throw new Exception("Conversion to compressed PNG failed. Is pngquant 1.8+ installed on the server?");
}
return $compressed_png_content;
}
$read_from_path = "pic.png";
$save_to_path = "compressed_file.png";
$compressed_png_content = compress_png($read_from_path,60);
file_put_contents($save_to_path, $compressed_png_content);
Именно об этом я и говорил когда спрашивал как установить pngquant...Fatal error: Uncaught exception 'Exception' with message 'Conversion to compressed PNG failed. Is pngquant 1.8+ installed on the server?'
Stack trace: compress_png('pic.png', 60) #1 {main} thrown in
мельком появляющуюся и пропадающую командную строкуЧто ты видишь, когда ты запускаешь эту дрянь из командной строки под тем же пользователем?
Именно об этом ты бы говорил, если бы всё это находилось в твоем самом первом посте.Именно об этом я и говорил когда спрашивал как установить pngquant...
Это как понимать..?мельком появляющуюся и пропадающую командную строку
pngquant, 2.1.1 (February 2014), by Greg Roelofs, Kornel Lesinski.
Compiled with libpng 1.6.3; using libpng 1.6.3.
usage: pngquant [options] [ncolors] [pngfile [pngfile ...]]
options:
--force overwrite existing output files (synonym: -f)
--nofs disable Floyd-Steinberg dithering
--ext new.png set custom suffix/extension for output filename
--output output path, only if one input file is specified (synonym: -
o)
--speed N speed/quality trade-off. 1=slow, 3=default, 11=fast & rough
--quality min-max don't save below min, use less colors below max (0-100)
--verbose print status messages (synonym: -v)
Quantizes one or more 32-bit RGBA PNGs to 8-bit (or smaller) RGBA-palette
PNGs using Floyd-Steinberg diffusion dithering (unless disabled).
The output filename is the same as the input name except that
it ends in "-fs8.png", "-or8.png" or your custom extension (unless the
input is stdin, in which case the quantized image will go to stdout).
The default behavior if the output file exists is to skip the conversion;
use --force to overwrite.
C:\pngquant-windows>