h2non / bimg

Go package for fast high-level image processing powered by libvips C library
https://pkg.go.dev/github.com/h2non/bimg?tab=doc
MIT License
2.69k stars 337 forks source link

EXIF data in JPEGs behaviour divergence from vips CLI #182

Open haf opened 7 years ago

haf commented 7 years ago

Via lib

➜  app✗ curl --silent  -F file=@app/dev/Thumbnails/receipt-1.jpg -X POST http://localhost:1234/autorotate >rotated.jpg
➜  app✗ identify -verbose rotated.jpg
Image: rotated.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 3024x4032+0+0
  Units: Undefined
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Pixels: 12192768
    Red:
      min: 3 (0.0117647)
      max: 255 (1)
      mean: 149.917 (0.58791)
      standard deviation: 83.9237 (0.329113)
      kurtosis: -1.70252
      skewness: -0.282173
      entropy: 0.878328
    Green:
      min: 12 (0.0470588)
      max: 255 (1)
      mean: 149.563 (0.58652)
      standard deviation: 79.7579 (0.312776)
      kurtosis: -1.72007
      skewness: -0.280422
      entropy: 0.876578
    Blue:
      min: 7 (0.027451)
      max: 255 (1)
      mean: 144.713 (0.567503)
      standard deviation: 79.8416 (0.313104)
      kurtosis: -1.72189
      skewness: -0.289887
      entropy: 0.881899
  Image statistics:
    Overall:
      min: 0 (0)
      max: 252 (0.988235)
      mean: 106.936 (0.419356)
      standard deviation: 81.2324 (0.318558)
      kurtosis: -1.70897
      skewness: -0.28169
      entropy: 0.878935
  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: 3024x4032+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 80
  Orientation: Undefined
  Properties:
    date:create: 2017-08-21T19:44:03+02:00
    date:modify: 2017-08-21T19:44:03+02:00
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x2,1x1,1x1
    signature: bb04d8249271d5fa916e580a39d1eb121e5aff58de92df1353b3b184c4a61a96
  Artifacts:
    filename: rotated.jpg
    verbose: true
  Tainted: False
  Filesize: 1.08374MiB
  Number pixels: 12.1928M
  Pixels per second: 53.012MB
  User time: 0.220u
  Elapsed time: 0:01.230
  Version: ImageMagick 6.9.9-8 Q16 x86_64 2017-08-20 http://www.imagemagick.org

via CLI

➜  app✗ vips autorot app/dev/Thumbnails/receipt-1.jpg rotated-cli.jpg
➜  app✗ identify -verbose rotated-cli.jpg
Image: rotated-cli.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 3024x4032+0+0
  Resolution: 1828.8x1828.8
  Print size: 1.65354x2.20472
  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: 12192768
    Red:
      min: 4 (0.0156863)
      max: 255 (1)
      mean: 149.955 (0.588058)
      standard deviation: 83.6837 (0.328171)
      kurtosis: -1.70201
      skewness: -0.28225
      entropy: 0.878981
    Green:
      min: 12 (0.0470588)
      max: 255 (1)
      mean: 149.42 (0.585962)
      standard deviation: 79.8754 (0.313237)
      kurtosis: -1.7197
      skewness: -0.280999
      entropy: 0.875675
    Blue:
      min: 6 (0.0235294)
      max: 255 (1)
      mean: 145.062 (0.568869)
      standard deviation: 79.7811 (0.312867)
      kurtosis: -1.72306
      skewness: -0.288275
      entropy: 0.880043
  Image statistics:
    Overall:
      min: 0 (0)
      max: 251 (0.984314)
      mean: 106.854 (0.419037)
      standard deviation: 81.1634 (0.318288)
      kurtosis: -1.70995
      skewness: -0.281484
      entropy: 0.878233
  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: 3024x4032+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 75
  Orientation: TopLeft
  Properties:
    date:create: 2017-08-21T19:44:35+02:00
    date:modify: 2017-08-21T19:44:35+02:00
    exif:ColorSpace: 1
    exif:ExifImageLength: 4032
    exif:ExifImageWidth: 3024
    exif:ExifOffset: 90
    exif:ExifVersion: 48, 50, 49, 48
    exif:FlashPixVersion: 48, 49, 48, 48
    exif:Orientation: 1
    exif:ResolutionUnit: 2
    exif:XResolution: 1828800/1000
    exif:YResolution: 1828800/1000
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x2,1x1,1x1
    signature: 455f36d4181b0a3f0e51fe44bb7a48e540045892550c912c7c0c6805e02fb34a
  Profiles:
    Profile-8bim: 40 bytes
    Profile-exif: 162 bytes
    Profile-iptc: 0 bytes
  Artifacts:
    filename: rotated-cli.jpg
    verbose: true
  Tainted: False
  Filesize: 996532B
  Number pixels: 12.1928M
  Pixels per second: 58.0608MB
  User time: 0.200u
  Elapsed time: 0:01.210
  Version: ImageMagick 6.9.9-8 Q16 x86_64 2017-08-20 http://www.imagemagick.org
Dynom commented 7 years ago

A diff is here: https://www.diffchecker.com/DSFepIxl