具有相同分辨率,相同像素数量但一个的图像比另一个大3倍

时间:2017-03-02 20:41:30

标签: image canvas jpeg

我正在处理来自HTML5画布的两个图像,使用toDataUrl()将其导出到base64并生成这些图像文件,它们具有相同数量的像素和相同的分辨率,但是一个图像文件的尺寸比另一个大3倍之一。

这是小尺寸图片(1MB):

这是一个大尺寸(3MB):

如您所见,唯一的区别是网格中的黑点。

这是图像magick的识别详细输出。 对于非虚线图像:

Image: pontoSem.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 1805x1520+0+0
Resolution: 72x72
Units: PixelsPerInch
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
  red: 8-bit
  green: 8-bit
  blue: 8-bit
Channel statistics:
  Pixels: 2743600
  Red:
    min: 0 (0)
    max: 255 (1)
    mean: 239.227 (0.938144)
    standard deviation: 50.1041 (0.196486)
    kurtosis: 9.08055
    skewness: -3.19968
  Green:
    min: 0 (0)
    max: 255 (1)
    mean: 241.654 (0.947662)
    standard deviation: 44.0232 (0.17264)
    kurtosis: 9.84544
    skewness: -3.28708
  Blue:
    min: 0 (0)
    max: 255 (1)
    mean: 239.038 (0.937403)
    standard deviation: 50.3878 (0.197599)
    kurtosis: 8.93501
    skewness: -3.18354
Image statistics:
  Overall:
    min: 0 (0)
    max: 255 (1)
    mean: 239.973 (0.94107)
    standard deviation: 48.2611 (0.189259)
    kurtosis: 9.42491
    skewness: -3.24166
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: 1805x1520+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 100
Orientation: Undefined
Properties:
  date:create: 2017-03-02T16:56:35-03:00
  date:modify: 2017-03-02T16:52:35-03:00
  jpeg:colorspace: 2
  jpeg:sampling-factor: 2x2,1x1,1x1
  signature: 23b092dd21773df0a63a3fffe8241f9916354e3d29638979d672e9cb91026c25
Artifacts:
  filename: pontoSem.jpg
  verbose: true
Tainted: False
Filesize: 1.063MB
Number pixels: 2.744M
Pixels per second: 45.73MB
User time: 0.040u
Elapsed time: 0:01.060
Version: ImageMagick 6.8.9-9 Q16 x86_64 2017-02-22

这是最大图像(虚线图像)的识别

Image: pontoCom.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 1805x1520+0+0
Resolution: 72x72
Print size: 25.0694x21.1111
Units: PixelsPerInch
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
  red: 8-bit
  green: 8-bit
  blue: 8-bit
Channel statistics:
  Pixels: 2743600
  Red:
    min: 0 (0)
    max: 255 (1)
    mean: 239.227 (0.938144)
    standard deviation: 50.1041 (0.196486)
    kurtosis: 9.08055
    skewness: -3.19968
  Green:
    min: 0 (0)
    max: 255 (1)
    mean: 241.654 (0.947662)
    standard deviation: 44.0232 (0.17264)
    kurtosis: 9.84544
    skewness: -3.28708
  Blue:
    min: 0 (0)
    max: 255 (1)
    mean: 239.038 (0.937403)
    standard deviation: 50.3878 (0.197599)
    kurtosis: 8.93501
    skewness: -3.18354
Image statistics:
  Overall:
    min: 0 (0)
    max: 255 (1)
    mean: 239.973 (0.94107)
    standard deviation: 48.2611 (0.189259)
    kurtosis: 9.42491
    skewness: -3.24166
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: 1805x1520+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 100
Orientation: Undefined
Properties:
  date:create: 2017-03-02T16:56:35-03:00
  date:modify: 2017-03-02T16:52:35-03:00
  jpeg:colorspace: 2
  jpeg:sampling-factor: 2x2,1x1,1x1
  signature: 23b092dd21773df0a63a3fffe8241f9916354e3d29638979d672e9cb91026c25
Artifacts:
  filename: pontoSem.jpg
  verbose: true
Tainted: False
Filesize: 1.063MB
Number pixels: 2.744M
Pixels per second: 45.73MB
User time: 0.040u
Elapsed time: 0:01.060
Version: ImageMagick 6.8.9-9 Q16 x86_64 2017-02-22 

我只是想知道为什么添加一些黑点使文件大小增加三倍,因为它们具有相同的像素数和sape dpi分辨率。 谢谢你的建议:)

2 个答案:

答案 0 :(得分:1)

由于压缩,第一张图像上的白色方块比具有更多随机性的第二张图像更容易压缩,因为图像描述符表示它使用JPEG压缩。 由于表面区域的大部分区域都使用此背景,因此它会影响整体尺寸,因为它会影响压缩算法的效率。

答案 1 :(得分:1)

Jpeg格式使用一些巧妙的技巧来减少原始位图图像的图像大小。取决于所表示的特定图像,这些技术具有不同的成功,并且当在靠近的像素之间没有明显差异时通常更好地工作。白色背景上的黑点正是让它变得困难的事情。

在第一张图片中,很多空间可以描述为"这个区域都是白色的"而第二个需要更长的描述,提到每个像素的颜色,无论那些黑色像素在哪里,几乎无处不在