[請益] bmp 壓縮問題

作者: altecjc (嘉誠)   2018-10-30 20:16:48
大大們好:
我需要匯出一張 bmp檔,檔案大小看能否壓縮越小越好(至少一定要小於 2mb)
我有一張 bg.png,要在上面加一些文字,程式類似這樣:
// 46kb
$filePath = '/images/bg.png';
// 載入背景圖
$im = imagecreatefrompng($filePath);
// 載入字體
$font = '/fonts/NotoSansCJKtc-Medium.otf';
// 文字黑色
$txtColor = imagecolorallocate($im, 0, 0, 0);
// 在背景圖上加文字
imagettftext($im, 22, 0, 320, 120, $txtColor, $font, '測試文字');
// 把圖片變成黑白
imagefilter($im, IMG_FILTER_GRAYSCALE);
// 輸出後就變成 2.1mb
$outputPath = $_SERVER['DOCUMENT_ROOT'].'/images/output.bmp';
imagebmp($im, $outputPath);
** 一定要輸出 BMP 檔案格式
** 使用 ai 壓縮可以變成 1.4mb 但經過 imagebmp() 就又變成 2.1mb
就算我不加入文字,只有把 png 轉成 bmp,也是 2.1mb
囧,有哪邊可以刪減之類嗎?
或是我對這個問題有什麼觀念上的誤解
希望高手大師們願意給我一盞明燈(關鍵字)
打擾了!
作者: wotupset (wotupset)   2018-10-30 20:38:00
jpg?
作者: tentenlee (天天)   2018-10-30 20:39:00
bmp是點陣圖無壓縮,請轉jpg or png
作者: cs8425 (cs)   2018-10-30 22:33:00
我記得bmp有壓縮的變種 只是支援度就... 還是乖乖jpg或png
作者: tentenlee (天天)   2018-10-31 14:15:00
一定要bmp無啥解了吧 檔案格式的問題
作者: NioTW (Nio)   2018-11-02 00:16:00
來源圖檔尺寸問題,1px一個值,尺寸多大檔案就多大

Links booklink

Contact Us: admin [ a t ] ucptt.com