Command-Line
如何使用 jpegoptim 使文件大小僅為 20kb?
我嘗試過使用 jpegoptim,甚至嘗試過聯機幫助頁,但我很難過。這是我想減少到 50k 甚至打開以降低數據質量的文件 -
Image: Filename: shirish.jpg Format: JPEG (Joint Photographic Experts Group JFIF format) Mime type: image/jpeg Class: DirectClass Geometry: 4624x3468+0+0 Resolution: 72x72 Print size: 64.2222x48.1667 Units: PixelsPerInch Colorspace: sRGB Type: TrueColor Base type: Undefined Endianness: Undefined Depth: 8-bit Channel depth: red: 8-bit green: 8-bit blue: 8-bit Channel statistics: Pixels: 16036032 Red: min: 0 (0) max: 255 (1) mean: 119.779 (0.46972) standard deviation: 60.359 (0.236702) kurtosis: -1.33094 skewness: -0.2895 entropy: 0.920909 Green: min: 0 (0) max: 255 (1) mean: 115.071 (0.45126) standard deviation: 63.5402 (0.249177) kurtosis: -1.51367 skewness: -0.162973 entropy: 0.912909 Blue: min: 0 (0) max: 255 (1) mean: 114.566 (0.449277) standard deviation: 61.8685 (0.242621) kurtosis: -1.51015 skewness: -0.101152 entropy: 0.912805 Image statistics: Overall: min: 0 (0) max: 255 (1) mean: 116.472 (0.456752) standard deviation: 61.9226 (0.242834) kurtosis: -1.46062 skewness: -0.184944 entropy: 0.915541 Rendering intent: Perceptual Gamma: 0.454545 Chromaticity: red primary: (0.64,0.33) green primary: (0.3,0.6) blue primary: (0.15,0.06) white point: (0.3127,0.329) Background color: white Border color: srgb(223,223,223) Matte color: grey74 Transparent color: black Interlace: None Intensity: Undefined Compose: Over Page geometry: 4624x3468+0+0 Dispose: Undefined Iterations: 0 Compression: JPEG Quality: 92 Orientation: RightTop Profiles: Profile-app4: 7600 bytes Profile-exif: 51509 bytes Properties: date:create: 2022-08-20T05:27:53+00:00 date:modify: 2022-08-20T05:27:53+00:00 exif:ApertureValue: 169/100 exif:BrightnessValue: 264/100 exif:ColorSpace: 1 exif:DateTime: 2022:08:20 10:53:10 exif:DateTimeDigitized: 2022:08:20 10:53:10 exif:DateTimeOriginal: 2022:08:20 10:53:10 exif:DigitalZoomRatio: 100/100 exif:ExifOffset: 226 exif:ExifVersion: 48, 50, 50, 48 exif:ExposureMode: 0 exif:ExposureProgram: 2 exif:ExposureTime: 1/50 exif:Flash: 0 exif:FNumber: 180/100 exif:FocalLength: 532/100 exif:FocalLengthIn35mmFilm: 28 exif:ImageLength: 3468 exif:ImageUniqueID: I64ELODR0PM exif:ImageWidth: 4624 exif:Make: samsung exif:MaxApertureValue: 169/100 exif:MeteringMode: 2 exif:Model: SM-M526B exif:OffsetTime: +05:30 exif:OffsetTimeOriginal: +05:30 exif:PhotographicSensitivity: 160 exif:PixelXDimension: 4624 exif:PixelYDimension: 3468 exif:SceneCaptureType: 0 exif:ShutterSpeedValue: 1/50 exif:Software: M526BXXU1BVG4 exif:thumbnail:Compression: 6 exif:thumbnail:ImageLength: 384 exif:thumbnail:ImageWidth: 512 exif:thumbnail:JPEGInterchangeFormat: 782 exif:thumbnail:JPEGInterchangeFormatLength: 50721 exif:thumbnail:ResolutionUnit: 2 exif:thumbnail:XResolution: 72/1 exif:thumbnail:YResolution: 72/1 exif:WhiteBalance: 0 exif:YCbCrPositioning: 1 jpeg:colorspace: 2 jpeg:sampling-factor: 2x2,1x1,1x1 signature: 7841c1e0cbe1aa5b79f0dea6791ffd321e2cf05715a9ab3cd210fd551c9bf355 Artifacts: filename: shirish.jpg verbose: true Tainted: False Filesize: 3.65599MiB Number pixels: 16.036M Pixels per second: 126.41MB User time: 0.120u Elapsed time: 0:01.126 Version: ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25 https://imagemagick.org
現在我嘗試了 imagemagick convert 和 jpegoptim 來獲得一個大約 50k 的文件。我需要那個大小的文件,因為我必須把它上傳到某個地方並且有大小限制。
我使用 imagemagick 中的 identify -verbose 開關獲得了上述 exif 和照片數據。
有人可以在上面幫助我。
我確實嘗試了以下 -
$jpegoptim --size=50k shirish.jpg
我得到了一個 200 kb 的文件,而不是 50kb,這很好,但不是我想要的 :(
我什至試過——
$jpegoptim --max=10 --size=50k shirish-aadhar-2-reduced.jpg
但即使這樣也沒有產生預期的結果。
$ jpegoptim --version jpegoptim v1.4.7 x86_64-pc-linux-gnu (Jun 20 2022) Copyright (C) 1996-2022, Timo Kokkonen This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistirbute it under certain conditions. See the GNU General Public License for more details. libjpeg version: 6b 27-Mar-1998 Copyright (C) 1991-2021 The libjpeg-turbo Project and many others
期待幫助。我知道我可以使用一些線上工具,但希望可以離線使用。
您可以使用 ImageMagick 去除所有元數據並降低質量。檢查此答案以獲取更多資訊:
85
漸進式(混合壓縮)中的質量
用於優化大小(半徑 0.05 或 0.5)的非常微小的高斯模糊取決於圖片的質量和大小,這顯著
優化了 jpeg 的大小。
剝離任何評論或 EXIF 元數據
在 imagemagick 中應該是
convert -strip -interlace Plane -gaussian-blur 0.05 -quality 85% source.jpg result.jpg
或在較新的版本中:
magick source.jpg -strip -interlace Plane -gaussian-blur 0.05 -quality 85% result.jpg
你可以玩
-quality
數字。但是將 16MP 圖像壓縮到 50k 會產生不那麼令人愉快的結果。