วิธีบีบอัดอิมเมจ jpg ใน Linux


9

ฉันรู้ว่ามี 'jpegoptim' ให้ทำเช่นนั้น แต่ไม่ได้ลดขนาดภาพตามที่คาดไว้เสมอไป ตัวอย่างเช่นถ้าฉันรัน

jpegoptim --max=50 *.jpg

สำหรับภาพขนาด 550KB ขนาดจะไม่ลดลงจริงๆ ดังนั้นฉันสงสัยว่ามีเครื่องมือที่มีประสิทธิภาพมากกว่านี้หรือไม่

ขอบคุณ

คำตอบ:


14

คุณสามารถลอง mogrify:

http://www.imagemagick.org/www/mogrify.html

ดูตัวอย่างเฉพาะสำหรับการบีบอัดภาพ:

/ubuntu/25356/decrease-filesize-when-resizing-with-mogrify

mogrify -quality 80 -resize 80 file.jpg

ดังนั้นคุณควรจะจบลงด้วยสิ่งที่ชอบ

mogrify -quality 80 file.jpg

ทดสอบจากเครื่องของฉัน:

aaron@sandbox:~/img-test$ du -h splash.jpg 
188K    splash.jpg
aaron@sandbox:~/img-test$ mogrify -quality 10 splash.jpg
aaron@sandbox:~/img-test$ du -h splash.jpg 
16K splash.jpg

ที่ 10% มันดูแย่มาก แต่คุณเข้าใจ

คุณสามารถใช้ Python PIL:

/programming/4353019/in-pythons-pil-how-do-i-change-the-quality-of-an-image

จากภาพการนำเข้า PIL

im = Image.open ("C: \ Users \ Public \ Pictures \ Sample รูปภาพ \ Jellyfish.jpg") im.save ("C: \ Users \ Public \ Pictures \ ตัวอย่างรูปภาพ \ Jellyfish_compressed.jpg", คุณภาพ = 10)

โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.