Размер файла изображения меньше формы base64 кодировать

Есть буксирное изображение в формате base64 ($theme_image_enc а также $theme_image_enc_little). Теперь я хочу сделать второе изображение ($theme_image_enc_little) размер меньше, как 15 КБ. Как это сделать?

    $image              = ($_FILES["my_image"]["name"]);
$theme_image        = ($_FILES["my_image"]["tmp_name"]);
$bin_string         = file_get_contents("$theme_image");
$theme_image_enc    = base64_encode($bin_string);

$WIDTH      = 400; // The size of your new image
$HEIGHT     = 300;  // The size of your new image
$QUALITY    = 100; //The quality of your new image
$org_w      = 850;
$org_h      = 660;

$theme_image_little     = imagecreatefromstring(base64_decode($theme_image_enc));
$image_little           = imagecreatetruecolor($WIDTH, $HEIGHT);
imagecopyresampled($image_little, $theme_image_little, 0, 0, 0, 0, $WIDTH, $HEIGHT, $org_w, $org_h);
ob_start();
imagepng($image_little);
$contents =  ob_get_contents();
ob_end_clean();

echo $theme_image_enc_little = base64_encode($contents);

0

Решение

попытаться показать низкий размер изображения в браузере, вам нужно уменьшить качество с помощью imagejpeg функция

// Take value between $quality = (0 < 100)

imagejpeg($theme_image_enc_little, NULL, $quality);
0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector