Coder Social home page Coder Social logo

Comments (16)

bfitzsimmons avatar bfitzsimmons commented on June 15, 2024 1

It looks like I may have found my answer. I'm now setting the format right before GetImageBlob() and it appears to be working. I'll try it out for a bit and close this if I can confirm it.

BTW, I'm using this lib. for an app that will be powering the majority of Natgeo's photo output, so I plan to be using the heck out of it. I'm sure we'll be talking again. :)

Thanks again for your help.

from imagick.

bfitzsimmons avatar bfitzsimmons commented on June 15, 2024

I modified my script a bit. It just sets the image format and sends some more output to the console. Here's the revised version:

package main

import (
    "fmt"
    "github.com/bfitzsimmons/imagick/imagick"
)

func main() {
    const (
        original_filepath = "/Users/bfitzsimmons/Pictures/test/plant.jpg"
        output1           = "/Users/bfitzsimmons/Pictures/test/plant_1.jpg"
    )

    var (
        err       error
        new_width uint
    )

    // Set up imagick.
    imagick.Initialize()
    defer imagick.Terminate()

    mw := imagick.NewMagickWand()
    defer mw.Destroy()

    // Open and load the file.
    if err = mw.ReadImage(original_filepath); err != nil {
        panic(err)
    }

    // Get the width and height.
    width := mw.GetImageWidth()
    height := mw.GetImageHeight()
    ratio := float64(width) / float64(height)

    if width > 1000 {
        new_width = 1000
    } else {
        new_width = width
    }

    final_width := new_width
    final_height := int(float64(new_width) / ratio)

    // Set the quality.
    if err = mw.SetImageCompressionQuality(85); err != nil {
        panic(err)
    }

    // Resize it.
    if err = mw.ResizeImage(uint(final_width), uint(final_height), imagick.FILTER_LANCZOS, 1); err != nil {
        panic(err)
    }

    // fmt.Println(mw.GetImageInterlaceScheme())

    if err = mw.SetImageInterlaceScheme(imagick.INTERLACE_LINE); err != nil {
        panic(err)
    }

    if err = mw.SetImageFormat("PJPEG"); err != nil {
        panic(err)
    }

    // mw.ResetIterator()

    fmt.Println(mw.GetImageFormat())
    fmt.Println(mw.GetImageInterlaceScheme())

    // Write it out to a file.
    if err = mw.WriteImage(output1); err != nil {
        panic(err)
    }
}

I also added some output to the imagick WriteImage function to verify that the image data referenced in the function did actually have the modified interlace scheme (it did). Here is the revised function:

// Writes an image to the specified filename.
func (mw *MagickWand) WriteImage(filename string) error {
    fmt.Println(mw.IdentifyImage())
    csfilename := C.CString(filename)
    defer C.free(unsafe.Pointer(csfilename))
    C.MagickWriteImage(mw.mw, csfilename)
    return mw.GetLastError()
}

Aaaaannnd...here's the execution of my script:

$ go run image_resizing1.go && identify -verbose /Users/bfitzsimmons/Pictures/test/plant_1.jpg | grep Interlace
PJPEG
2
Image: /Users/bfitzsimmons/Pictures/test/plant.jpg
  Format: PJPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 1000x664+0+0
  Base geometry: 3008x2000
  Resolution: 240x240
  Print size: 4.16667x2.76667
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8/16-bit
  Channel depth:
    red: 16-bit
    green: 16-bit
    blue: 16-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 211 (0.826825)
      mean: 103.028 (0.404032)
      standard deviation: 29.9733 (0.117542)
      kurtosis: -0.0430463
      skewness: 0.524367
    Green:
      min: 14 (0.0553597)
      max: 226 (0.884352)
      mean: 144.233 (0.56562)
      standard deviation: 24.8883 (0.0976012)
      kurtosis: 0.93005
      skewness: -0.654038
    Blue:
      min: 0 (0)
      max: 206 (0.807675)
      mean: 73.7504 (0.289217)
      standard deviation: 49.1457 (0.192728)
      kurtosis: -0.930755
      skewness: -0.0294567
  Image statistics:
    Overall:
      min: 0 (0)
      max: 226 (0.884352)
      mean: 107.004 (0.419623)
      standard deviation: 36.2083 (0.141993)
      kurtosis: 4.58466
      skewness: -1.1739
  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: Line
  Intensity: Undefined
  Compose: Over
  Page geometry: 1000x664+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 85
  Orientation: Undefined
  Properties:
    date:create: 2014-05-04T01:55:05-04:00
    date:modify: 2013-12-31T03:08:09-05:00
    exif:ApertureValue: 4643856/1000000
    exif:CFAPattern: 2, 0, 2, 0, 2, 1, 1, 0
    exif:Compression: 6
    exif:Contrast: 0
    exif:CustomRendered: 0
    exif:DateTime: 2013:12:31 03:08:09
    exif:DateTimeDigitized: 2010:05:21 17:43:30
    exif:DateTimeOriginal: 2010:05:21 17:43:30
    exif:DigitalZoomRatio: 1/1
    exif:ExifOffset: 216
    exif:ExifVersion: 48, 50, 51, 48
    exif:ExposureBiasValue: 0/6
    exif:ExposureMode: 0
    exif:ExposureProgram: 2
    exif:ExposureTime: 1/100
    exif:FileSource: 3
    exif:Flash: 0
    exif:FNumber: 5/1
    exif:FocalLength: 350/10
    exif:FocalLengthIn35mmFilm: 52
    exif:GainControl: 0
    exif:ISOSpeedRatings: 200
    exif:JPEGInterchangeFormat: 902
    exif:JPEGInterchangeFormatLength: 10181
    exif:LightSource: 0
    exif:Make: NIKON CORPORATION
    exif:MaxApertureValue: 16/10
    exif:MeteringMode: 2
    exif:Model: NIKON D40
    exif:ResolutionUnit: 2
    exif:Saturation: 0
    exif:SceneCaptureType: 0
    exif:SceneType: 1
    exif:SensingMethod: 2
    exif:Sharpness: 0
    exif:ShutterSpeedValue: 6643856/1000000
    exif:Software: Adobe Photoshop Lightroom 5.3 (Macintosh)
    exif:SubjectDistanceRange: 0
    exif:SubSecTimeDigitized: 90
    exif:SubSecTimeOriginal: 90
    exif:WhiteBalance: 0
    exif:XResolution: 240/1
    exif:YResolution: 240/1
    jpeg:colorspace: 2
    jpeg:sampling-factor: 1x1,1x1,1x1
    signature: 4df840ddd9b9b259f5215fbae61e6e33a664e58058f0e8023c07f2516cd57228
    unknown: 3288747
    xmpMM:DerivedFrom:
  Profiles:
    Profile-8bim: 10354 bytes
    Profile-exif: 11089 bytes
    Profile-icc: 3144 bytes
    Profile-iptc: 63 bytes
      City[1,90]: 0x00000000: 254700                                        -%
      unknown[2,0]:
      Created Date[2,55]: 20100521
      Created Time[2,60]: 174330
      unknown[2,62]: 20100521
      unknown[2,63]: 174330
    Profile-xmp: 9478 bytes
  Tainted: True
  Filesize: 0B
  Number pixels: 664K
  Pixels per second: 2.887MB
  User time: 0.240u
  Elapsed time: 0:01.230
  Version: ImageMagick 6.8.8-9 Q16 x86_64 2014-03-23 http://www.imagemagick.org

  Interlace: None

As you can see, the data referenced in the function has the correct scheme, but the resulting file does not. As mentioned in the title of the issue, this occurs when outputting the data as a blob as well.

Please let me know if you need any additional information. Thanks again.

from imagick.

justinfx avatar justinfx commented on June 15, 2024

Have you tried setting "pjpeg" first and then setting the interlace scheme
to line?
On May 10, 2014 8:35 AM, "Brant Fitzsimmons" [email protected]
wrote:

I modified my script a bit. It just sets the image format and sends some
more output to the console. Here's the revised version:

package main
import (
"fmt"
"github.com/bfitzsimmons/imagick/imagick")
func main() {
const (
original_filepath = "/Users/bfitzsimmons/Pictures/test/plant.jpg"
output1 = "/Users/bfitzsimmons/Pictures/test/plant_1.jpg"
)

var (
    err       error
    new_width uint
)

// Set up imagick.
imagick.Initialize()
defer imagick.Terminate()

mw := imagick.NewMagickWand()
defer mw.Destroy()

// Open and load the file.
if err = mw.ReadImage(original_filepath); err != nil {
    panic(err)
}

// Get the width and height.
width := mw.GetImageWidth()
height := mw.GetImageHeight()
ratio := float64(width) / float64(height)

if width > 1000 {
    new_width = 1000
} else {
    new_width = width
}

final_width := new_width
final_height := int(float64(new_width) / ratio)

// Set the quality.
if err = mw.SetImageCompressionQuality(85); err != nil {
    panic(err)
}

// Resize it.
if err = mw.ResizeImage(uint(final_width), uint(final_height), imagick.FILTER_LANCZOS, 1); err != nil {
    panic(err)
}

// fmt.Println(mw.GetImageInterlaceScheme())

if err = mw.SetImageInterlaceScheme(imagick.INTERLACE_LINE); err != nil {
    panic(err)
}

if err = mw.SetImageFormat("PJPEG"); err != nil {
    panic(err)
}

// mw.ResetIterator()

fmt.Println(mw.GetImageFormat())
fmt.Println(mw.GetImageInterlaceScheme())

// Write it out to a file.
if err = mw.WriteImage(output1); err != nil {
    panic(err)
}}

I also added some output to the imagick WriteImage function to verify that
the image data referenced in the function did actually have the modified
interlace scheme (it did). Here is the revised function:

// Writes an image to the specified filename.func (mw *MagickWand) WriteImage(filename string) error {
fmt.Println(mw.IdentifyImage())
csfilename := C.CString(filename)
defer C.free(unsafe.Pointer(csfilename))
C.MagickWriteImage(mw.mw, csfilename)
return mw.GetLastError()}

Aaaaannnd...here's the execution of my script:

$ go run image_resizing1.go && identify -verbose /Users/bfitzsimmons/Pictures/test/plant_1.jpg | grep Interlace
PJPEG
2
Image: /Users/bfitzsimmons/Pictures/test/plant.jpg
Format: PJPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 1000x664+0+0
Base geometry: 3008x2000
Resolution: 240x240
Print size: 4.16667x2.76667
Units: PixelsPerInch
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8/16-bit
Channel depth:
red: 16-bit
green: 16-bit
blue: 16-bit
Channel statistics:
Red:
min: 0 (0)
max: 211 (0.826825)
mean: 103.028 (0.404032)
standard deviation: 29.9733 (0.117542)
kurtosis: -0.0430463
skewness: 0.524367
Green:
min: 14 (0.0553597)
max: 226 (0.884352)
mean: 144.233 (0.56562)
standard deviation: 24.8883 (0.0976012)
kurtosis: 0.93005
skewness: -0.654038
Blue:
min: 0 (0)
max: 206 (0.807675)
mean: 73.7504 (0.289217)
standard deviation: 49.1457 (0.192728)
kurtosis: -0.930755
skewness: -0.0294567
Image statistics:
Overall:
min: 0 (0)
max: 226 (0.884352)
mean: 107.004 (0.419623)
standard deviation: 36.2083 (0.141993)
kurtosis: 4.58466
skewness: -1.1739
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: Line
Intensity: Undefined
Compose: Over
Page geometry: 1000x664+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 85
Orientation: Undefined
Properties:
date:create: 2014-05-04T01:55:05-04:00
date:modify: 2013-12-31T03:08:09-05:00
exif:ApertureValue: 4643856/1000000
exif:CFAPattern: 2, 0, 2, 0, 2, 1, 1, 0
exif:Compression: 6
exif:Contrast: 0
exif:CustomRendered: 0
exif:DateTime: 2013:12:31 03:08:09
exif:DateTimeDigitized: 2010:05:21 17:43:30
exif:DateTimeOriginal: 2010:05:21 17:43:30
exif:DigitalZoomRatio: 1/1
exif:ExifOffset: 216
exif:ExifVersion: 48, 50, 51, 48
exif:ExposureBiasValue: 0/6
exif:ExposureMode: 0
exif:ExposureProgram: 2
exif:ExposureTime: 1/100
exif:FileSource: 3
exif:Flash: 0
exif:FNumber: 5/1
exif:FocalLength: 350/10
exif:FocalLengthIn35mmFilm: 52
exif:GainControl: 0
exif:ISOSpeedRatings: 200
exif:JPEGInterchangeFormat: 902
exif:JPEGInterchangeFormatLength: 10181
exif:LightSource: 0
exif:Make: NIKON CORPORATION
exif:MaxApertureValue: 16/10
exif:MeteringMode: 2
exif:Model: NIKON D40
exif:ResolutionUnit: 2
exif:Saturation: 0
exif:SceneCaptureType: 0
exif:SceneType: 1
exif:SensingMethod: 2
exif:Sharpness: 0
exif:ShutterSpeedValue: 6643856/1000000
exif:Software: Adobe Photoshop Lightroom 5.3 (Macintosh)
exif:SubjectDistanceRange: 0
exif:SubSecTimeDigitized: 90
exif:SubSecTimeOriginal: 90
exif:WhiteBalance: 0
exif:XResolution: 240/1
exif:YResolution: 240/1
jpeg:colorspace: 2
jpeg:sampling-factor: 1x1,1x1,1x1
signature: 4df840ddd9b9b259f5215fbae61e6e33a664e58058f0e8023c07f2516cd57228
unknown: 3288747
xmpMM:DerivedFrom:
Profiles:
Profile-8bim: 10354 bytes
Profile-exif: 11089 bytes
Profile-icc: 3144 bytes
Profile-iptc: 63 bytes
City[1,90]: 0x00000000: 254700 -%
unknown[2,0]:
Created Date[2,55]: 20100521
Created Time[2,60]: 174330
unknown[2,62]: 20100521
unknown[2,63]: 174330
Profile-xmp: 9478 bytes
Tainted: True
Filesize: 0B
Number pixels: 664K
Pixels per second: 2.887MB
User time: 0.240u
Elapsed time: 0:01.230
Version: ImageMagick 6.8.8-9 Q16 x86_64 2014-03-23 http://www.imagemagick.org

Interlace: None

As you can see, the data referenced in the function has the correct
scheme, but the resulting file does not. As mentioned in the title of the
issue, this occurs when outputting the data as a blob as well.

Please let me know if you need any additional information. Thanks again.


Reply to this email directly or view it on GitHubhttps://github.com//issues/15#issuecomment-42710529
.

from imagick.

bfitzsimmons avatar bfitzsimmons commented on June 15, 2024

I don't know if I've tried that specific order, but I'll try it right now.

from imagick.

bfitzsimmons avatar bfitzsimmons commented on June 15, 2024

I just tried it, and the results were the same.

from imagick.

bfitzsimmons avatar bfitzsimmons commented on June 15, 2024

The things that's getting me is the fact that the data appears to be correct when referenced in the WriteImage function. I can output the interlace scheme and the image format from inside it, and I get the expected result. Getting that, seemingly correct, data to return from the function is where I'm having my issue.

from imagick.

justinfx avatar justinfx commented on June 15, 2024

There doesn't seem to be much magic surrounding the Write code, as all it does it pass the want pointer and the filename directly to the C Write function. And you have confirmed that the values are all set, just before writing. What do you get if you then read back in that new image and dump it's properties?

from imagick.

bfitzsimmons avatar bfitzsimmons commented on June 15, 2024

Here's the original:

Image: /Users/bfitzsimmons/Pictures/test/plant.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 3008x2000+0+0
  Resolution: 240x240
  Print size: 12.5333x8.33333
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 213 (0.835294)
      mean: 103.028 (0.404032)
      standard deviation: 30.0476 (0.117834)
      kurtosis: -0.0453757
      skewness: 0.516439
    Green:
      min: 12 (0.0470588)
      max: 235 (0.921569)
      mean: 144.233 (0.56562)
      standard deviation: 24.983 (0.0979724)
      kurtosis: 0.928209
      skewness: -0.653489
    Blue:
      min: 0 (0)
      max: 211 (0.827451)
      mean: 73.7356 (0.289159)
      standard deviation: 49.2249 (0.193039)
      kurtosis: -0.930535
      skewness: -0.0313666
  Image statistics:
    Overall:
      min: 0 (0)
      max: 235 (0.921569)
      mean: 106.999 (0.419604)
      standard deviation: 36.2863 (0.142299)
      kurtosis: 4.56705
      skewness: -1.17211
  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: 3008x2000+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 99
  Orientation: Undefined
  Properties:
    date:create: 2014-05-04T01:55:05-04:00
    date:modify: 2013-12-31T03:08:09-05:00
    exif:ApertureValue: 4643856/1000000
    exif:CFAPattern: 2, 0, 2, 0, 2, 1, 1, 0
    exif:Compression: 6
    exif:Contrast: 0
    exif:CustomRendered: 0
    exif:DateTime: 2013:12:31 03:08:09
    exif:DateTimeDigitized: 2010:05:21 17:43:30
    exif:DateTimeOriginal: 2010:05:21 17:43:30
    exif:DigitalZoomRatio: 1/1
    exif:ExifOffset: 216
    exif:ExifVersion: 48, 50, 51, 48
    exif:ExposureBiasValue: 0/6
    exif:ExposureMode: 0
    exif:ExposureProgram: 2
    exif:ExposureTime: 1/100
    exif:FileSource: 3
    exif:Flash: 0
    exif:FNumber: 5/1
    exif:FocalLength: 350/10
    exif:FocalLengthIn35mmFilm: 52
    exif:GainControl: 0
    exif:ISOSpeedRatings: 200
    exif:JPEGInterchangeFormat: 902
    exif:JPEGInterchangeFormatLength: 10181
    exif:LightSource: 0
    exif:Make: NIKON CORPORATION
    exif:MaxApertureValue: 16/10
    exif:MeteringMode: 2
    exif:Model: NIKON D40
    exif:ResolutionUnit: 2
    exif:Saturation: 0
    exif:SceneCaptureType: 0
    exif:SceneType: 1
    exif:SensingMethod: 2
    exif:Sharpness: 0
    exif:ShutterSpeedValue: 6643856/1000000
    exif:Software: Adobe Photoshop Lightroom 5.3 (Macintosh)
    exif:SubjectDistanceRange: 0
    exif:SubSecTimeDigitized: 90
    exif:SubSecTimeOriginal: 90
    exif:WhiteBalance: 0
    exif:XResolution: 240/1
    exif:YResolution: 240/1
    jpeg:colorspace: 2
    jpeg:sampling-factor: 1x1,1x1,1x1
    signature: 0d896ce2775767783cbe54385e9b20623ca09b157aa23be23402313d2c7f256b
    unknown: 3288747
    xmpMM:DerivedFrom:
  Profiles:
    Profile-8bim: 10354 bytes
    Profile-exif: 11089 bytes
    Profile-icc: 3144 bytes
    Profile-iptc: 63 bytes
      City[1,90]: 0x00000000: 254700                                        -%
      unknown[2,0]:
      Created Date[2,55]: 20100521
      Created Time[2,60]: 174330
      unknown[2,62]: 20100521
      unknown[2,63]: 174330
    Profile-xmp: 9478 bytes
  Tainted: False
  Filesize: 2.973MB
  Number pixels: 6.016M
  Pixels per second: 42.97MB
  User time: 0.140u
  Elapsed time: 0:01.140
  Version: ImageMagick 6.8.8-9 Q16 x86_64 2014-03-23 http://www.imagemagick.org

Here's the output just before writing the file:

Image: /Users/bfitzsimmons/Pictures/test/plant.jpg
  Format: PJPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 1000x664+0+0
  Base geometry: 3008x2000
  Resolution: 240x240
  Print size: 4.16667x2.76667
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8/16-bit
  Channel depth:
    red: 16-bit
    green: 16-bit
    blue: 16-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 211 (0.826825)
      mean: 103.028 (0.404032)
      standard deviation: 29.9733 (0.117542)
      kurtosis: -0.0430463
      skewness: 0.524367
    Green:
      min: 14 (0.0553597)
      max: 226 (0.884352)
      mean: 144.233 (0.56562)
      standard deviation: 24.8883 (0.0976012)
      kurtosis: 0.93005
      skewness: -0.654038
    Blue:
      min: 0 (0)
      max: 206 (0.807675)
      mean: 73.7504 (0.289217)
      standard deviation: 49.1457 (0.192728)
      kurtosis: -0.930755
      skewness: -0.0294567
  Image statistics:
    Overall:
      min: 0 (0)
      max: 226 (0.884352)
      mean: 107.004 (0.419623)
      standard deviation: 36.2083 (0.141993)
      kurtosis: 4.58466
      skewness: -1.1739
  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: Line
  Intensity: Undefined
  Compose: Over
  Page geometry: 1000x664+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 85
  Orientation: Undefined
  Properties:
    date:create: 2014-05-04T01:55:05-04:00
    date:modify: 2013-12-31T03:08:09-05:00
    exif:ApertureValue: 4643856/1000000
    exif:CFAPattern: 2, 0, 2, 0, 2, 1, 1, 0
    exif:Compression: 6
    exif:Contrast: 0
    exif:CustomRendered: 0
    exif:DateTime: 2013:12:31 03:08:09
    exif:DateTimeDigitized: 2010:05:21 17:43:30
    exif:DateTimeOriginal: 2010:05:21 17:43:30
    exif:DigitalZoomRatio: 1/1
    exif:ExifOffset: 216
    exif:ExifVersion: 48, 50, 51, 48
    exif:ExposureBiasValue: 0/6
    exif:ExposureMode: 0
    exif:ExposureProgram: 2
    exif:ExposureTime: 1/100
    exif:FileSource: 3
    exif:Flash: 0
    exif:FNumber: 5/1
    exif:FocalLength: 350/10
    exif:FocalLengthIn35mmFilm: 52
    exif:GainControl: 0
    exif:ISOSpeedRatings: 200
    exif:JPEGInterchangeFormat: 902
    exif:JPEGInterchangeFormatLength: 10181
    exif:LightSource: 0
    exif:Make: NIKON CORPORATION
    exif:MaxApertureValue: 16/10
    exif:MeteringMode: 2
    exif:Model: NIKON D40
    exif:ResolutionUnit: 2
    exif:Saturation: 0
    exif:SceneCaptureType: 0
    exif:SceneType: 1
    exif:SensingMethod: 2
    exif:Sharpness: 0
    exif:ShutterSpeedValue: 6643856/1000000
    exif:Software: Adobe Photoshop Lightroom 5.3 (Macintosh)
    exif:SubjectDistanceRange: 0
    exif:SubSecTimeDigitized: 90
    exif:SubSecTimeOriginal: 90
    exif:WhiteBalance: 0
    exif:XResolution: 240/1
    exif:YResolution: 240/1
    jpeg:colorspace: 2
    jpeg:sampling-factor: 1x1,1x1,1x1
    signature: 4df840ddd9b9b259f5215fbae61e6e33a664e58058f0e8023c07f2516cd57228
    unknown: 3288747
    xmpMM:DerivedFrom:
  Profiles:
    Profile-8bim: 10354 bytes
    Profile-exif: 11089 bytes
    Profile-icc: 3144 bytes
    Profile-iptc: 63 bytes
      City[1,90]: 0x00000000: 254700                                        -%
      unknown[2,0]:
      Created Date[2,55]: 20100521
      Created Time[2,60]: 174330
      unknown[2,62]: 20100521
      unknown[2,63]: 174330
    Profile-xmp: 9478 bytes
  Tainted: True
  Filesize: 0B
  Number pixels: 664K
  Pixels per second: 2.767MB
  User time: 0.240u
  Elapsed time: 0:01.240
  Version: ImageMagick 6.8.8-9 Q16 x86_64 2014-03-23 http://www.imagemagick.org

Here's the output after re-reading in the output file:

Image: /Users/bfitzsimmons/Pictures/test/plant_1.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 1000x664+0+0
  Resolution: 240x240
  Print size: 4.16667x2.76667
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 224 (0.878431)
      mean: 103.083 (0.404247)
      standard deviation: 29.9739 (0.117545)
      kurtosis: -0.0405247
      skewness: 0.51901
    Green:
      min: 6 (0.0235294)
      max: 228 (0.894118)
      mean: 144.22 (0.565568)
      standard deviation: 24.8852 (0.0975889)
      kurtosis: 0.926971
      skewness: -0.651341
    Blue:
      min: 0 (0)
      max: 216 (0.847059)
      mean: 73.855 (0.289628)
      standard deviation: 48.9673 (0.192029)
      kurtosis: -0.930772
      skewness: -0.0196268
  Image statistics:
    Overall:
      min: 0 (0)
      max: 228 (0.894118)
      mean: 107.053 (0.419814)
      standard deviation: 36.1271 (0.141675)
      kurtosis: 4.54928
      skewness: -1.16025
  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: 1000x664+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 0 of 2
  Compression: JPEG
  Quality: 85
  Orientation: Undefined
  Properties:
    date:create: 2014-05-09T17:42:06-04:00
    date:modify: 2014-05-09T17:42:06-04:00
    exif:ApertureValue: 4643856/1000000
    exif:CFAPattern: 2, 0, 2, 0, 2, 1, 1, 0
    exif:Compression: 6
    exif:Contrast: 0
    exif:CustomRendered: 0
    exif:DateTime: 2013:12:31 03:08:09
    exif:DateTimeDigitized: 2010:05:21 17:43:30
    exif:DateTimeOriginal: 2010:05:21 17:43:30
    exif:DigitalZoomRatio: 1/1
    exif:ExifOffset: 216
    exif:ExifVersion: 48, 50, 51, 48
    exif:ExposureBiasValue: 0/6
    exif:ExposureMode: 0
    exif:ExposureProgram: 2
    exif:ExposureTime: 1/100
    exif:FileSource: 3
    exif:Flash: 0
    exif:FNumber: 5/1
    exif:FocalLength: 350/10
    exif:FocalLengthIn35mmFilm: 52
    exif:GainControl: 0
    exif:ISOSpeedRatings: 200
    exif:JPEGInterchangeFormat: 902
    exif:JPEGInterchangeFormatLength: 10181
    exif:LightSource: 0
    exif:Make: NIKON CORPORATION
    exif:MaxApertureValue: 16/10
    exif:MeteringMode: 2
    exif:Model: NIKON D40
    exif:ResolutionUnit: 2
    exif:Saturation: 0
    exif:SceneCaptureType: 0
    exif:SceneType: 1
    exif:SensingMethod: 2
    exif:Sharpness: 0
    exif:ShutterSpeedValue: 6643856/1000000
    exif:Software: Adobe Photoshop Lightroom 5.3 (Macintosh)
    exif:SubjectDistanceRange: 0
    exif:SubSecTimeDigitized: 90
    exif:SubSecTimeOriginal: 90
    exif:WhiteBalance: 0
    exif:XResolution: 240/1
    exif:YResolution: 240/1
    jpeg:colorspace: 2
    jpeg:sampling-factor: 1x1,1x1,1x1
    signature: 5c21f6ac467935cfacd23efb351eabaf59ea0412b1377b0a14627544ab864ecf
    unknown: 3288747
    xmpMM:DerivedFrom:
  Profiles:
    Profile-8bim: 10354 bytes
    Profile-exif: 11089 bytes
    Profile-iptc: 63 bytes
      City[1,90]: 0x00000000: 254700                                        -%
      unknown[2,0]:
      Created Date[2,55]: 20100521
      Created Time[2,60]: 174330
      unknown[2,62]: 20100521
      unknown[2,63]: 174330
    Profile-xmp: 9478 bytes
  Tainted: False
  Filesize: 120KB
  Number pixels: 664K
  Pixels per second: 66.4MB
  User time: 0.010u
  Elapsed time: 0:01.009
  Version: ImageMagick 6.8.8-9 Q16 x86_64 2014-03-23 http://www.imagemagick.org

from imagick.

bfitzsimmons avatar bfitzsimmons commented on June 15, 2024

I ran diffs between the three versions of the output and was surprised to see the ICC profile (present in both the original and in wand version) removed from the final output as well. Something for another discussion.

I also noted the addition of a Scene property in the re-read output:

Scene: 0 of 2

I'll have to look into that as well.

But, as it relates to this issue, I note that the re-read image is of the JPEG format, and not PJPEG, as desired, and Interlace is set to None.

Thanks for looking into this.

from imagick.

justinfx avatar justinfx commented on June 15, 2024

I was able to give it a test and am seeing something interesting. The output jpeg, like you have found, basically doesn't respond when the format is set to "PJPEG" and the interlace is set to "LINE". But in following the imagemagick filename prefixing syntax, this does appear to work:

    if err = mw.WriteImage(fmt.Sprintf("PJPEG:%s", output1)); err != nil {
        panic(err)
    }

It even still produces the "JPEG" value in the identify call, even without setting the PJPEG format or interlace. Maybe you want to compare the images?

from imagick.

bfitzsimmons avatar bfitzsimmons commented on June 15, 2024

Odd...

As you said, the Format is still set to "JPEG", but Interlace is, indeed, now set to "JPEG". It's halfway there. :)

Image: /Users/bfitzsimmons/Pictures/test/plant_1.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 1000x664+0+0
  Resolution: 240x240
  Print size: 4.16667x2.76667
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 224 (0.878431)
      mean: 103.083 (0.404247)
      standard deviation: 29.9739 (0.117545)
      kurtosis: -0.0405247
      skewness: 0.51901
    Green:
      min: 6 (0.0235294)
      max: 228 (0.894118)
      mean: 144.22 (0.565568)
      standard deviation: 24.8852 (0.0975889)
      kurtosis: 0.926971
      skewness: -0.651341
    Blue:
      min: 0 (0)
      max: 216 (0.847059)
      mean: 73.855 (0.289628)
      standard deviation: 48.9673 (0.192029)
      kurtosis: -0.930772
      skewness: -0.0196268
  Image statistics:
    Overall:
      min: 0 (0)
      max: 228 (0.894118)
      mean: 107.053 (0.419814)
      standard deviation: 36.1271 (0.141675)
      kurtosis: 4.54928
      skewness: -1.16025
  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: JPEG
  Intensity: Undefined
  Compose: Over
  Page geometry: 1000x664+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 0 of 2
  Compression: JPEG
  Quality: 85
  Orientation: Undefined
  Properties:
    date:create: 2014-05-09T18:22:43-04:00
    date:modify: 2014-05-09T18:22:43-04:00
    exif:ApertureValue: 4643856/1000000
    exif:CFAPattern: 2, 0, 2, 0, 2, 1, 1, 0
    exif:Compression: 6
    exif:Contrast: 0
    exif:CustomRendered: 0
    exif:DateTime: 2013:12:31 03:08:09
    exif:DateTimeDigitized: 2010:05:21 17:43:30
    exif:DateTimeOriginal: 2010:05:21 17:43:30
    exif:DigitalZoomRatio: 1/1
    exif:ExifOffset: 216
    exif:ExifVersion: 48, 50, 51, 48
    exif:ExposureBiasValue: 0/6
    exif:ExposureMode: 0
    exif:ExposureProgram: 2
    exif:ExposureTime: 1/100
    exif:FileSource: 3
    exif:Flash: 0
    exif:FNumber: 5/1
    exif:FocalLength: 350/10
    exif:FocalLengthIn35mmFilm: 52
    exif:GainControl: 0
    exif:ISOSpeedRatings: 200
    exif:JPEGInterchangeFormat: 902
    exif:JPEGInterchangeFormatLength: 10181
    exif:LightSource: 0
    exif:Make: NIKON CORPORATION
    exif:MaxApertureValue: 16/10
    exif:MeteringMode: 2
    exif:Model: NIKON D40
    exif:ResolutionUnit: 2
    exif:Saturation: 0
    exif:SceneCaptureType: 0
    exif:SceneType: 1
    exif:SensingMethod: 2
    exif:Sharpness: 0
    exif:ShutterSpeedValue: 6643856/1000000
    exif:Software: Adobe Photoshop Lightroom 5.3 (Macintosh)
    exif:SubjectDistanceRange: 0
    exif:SubSecTimeDigitized: 90
    exif:SubSecTimeOriginal: 90
    exif:WhiteBalance: 0
    exif:XResolution: 240/1
    exif:YResolution: 240/1
    jpeg:colorspace: 2
    jpeg:sampling-factor: 1x1,1x1,1x1
    signature: 5c21f6ac467935cfacd23efb351eabaf59ea0412b1377b0a14627544ab864ecf
    unknown: 3288747
    xmpMM:DerivedFrom:
  Profiles:
    Profile-8bim: 10354 bytes
    Profile-exif: 11089 bytes
    Profile-iptc: 63 bytes
      City[1,90]: 0x00000000: 254700                                        -%
      unknown[2,0]:
      Created Date[2,55]: 20100521
      Created Time[2,60]: 174330
      unknown[2,62]: 20100521
      unknown[2,63]: 174330
    Profile-xmp: 9478 bytes
  Tainted: False
  Filesize: 121KB
  Number pixels: 664K
  Pixels per second: 66.4MB
  User time: 0.020u
  Elapsed time: 0:01.009
  Version: ImageMagick 6.8.8-9 Q16 x86_64 2014-03-23 http://www.imagemagick.org

I'm not sure if this helps on the blob output, however.

from imagick.

justinfx avatar justinfx commented on June 15, 2024

Pretty sure the "PJPEG" thing is just a hint and not a formal format. When I use convert, it doesn't even say "PJPEG". The format is still jpeg.

from imagick.

bfitzsimmons avatar bfitzsimmons commented on June 15, 2024

Hmmm...

Any ideas on how to get the proper output from GetImageBlob() (which appears to have the same issue, and is why I wrote the test file in the first place)? The inability to specify a name prefix may be a problem.

from imagick.

justinfx avatar justinfx commented on June 15, 2024

This also seems to work fine for me, when using a blob:

    if err = mw.SetImageFormat("PJPEG"); err != nil {
        panic(err)
    }
    blob := mw.GetImageBlob()
    if err = ioutil.WriteFile(output1, blob, 0777); err != nil {
        panic(err)
    }

from imagick.

bfitzsimmons avatar bfitzsimmons commented on June 15, 2024

I saw your response appear just as I clicked the button for mine. I'm going to confirm that things are as they need to be, and, if so, I'll close this issue.

Thanks again.

from imagick.

justinfx avatar justinfx commented on June 15, 2024

Awesome. So I guess the rule of thumb is:

  1. Always set the format
  2. The interlace mode doesn't seem to make a different here
  3. Use the type prefix in the filename if using the mw.WriteImage

from imagick.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.