我尝试过使用 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 中的 recognize -verbose 开关获取了上述 exif 和照片数据。
有人可以帮我解决上述问题吗?
我确实尝试了以下操作 -
$jpegoptim --size=50k shirish.jpg
我得到的文件不是 50kb,而是 200kb,不错,但不是我想要的:(
我什至尝试过-
$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
期待帮助。我知道我可以使用一些在线工具来实现同样的目的,但希望可以离线使用。
答案1
您可以使用 ImageMagick 删除所有元数据并降低质量。查看这个答案欲了解更多信息:
85 渐进式质量
(comprobed 压缩)
优化尺寸(半径的 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 会产生不太令人愉快的结果。
答案2
鉴于格式为 jpg,可以定义最大文件大小:
convert shirish.jpg -define jpeg:extent=20k shirish-20k.jpg
这几乎肯定会大大降低图像质量。
但这是值得了解的。