Images not returning pixels

Hello,
I recently tried downloading a few random images and then getting their pixel values via either mouse over the image or just printing out all the pixel values by looping through them. Just a note, display the image works fine.

What happens is with most images I get a return of 0-255 for RGBA values but certain images return 0,0,0,255 and the warning ofLog(OF_LOG_ERROR,“ofPixels: image type not supported”); both images I’m testing with are .jpg and when I open inspector on them they are both RGB. Here are the images I’m using:

image.resize(1);
image.load("test.jpg");
image.setImageType(OF_IMAGE_COLOR_ALPHA); // NOTE: I've tried running this and also commented out
   
unsigned char *data = image.getPixels().getData();

int components = image.getPixels().getBitsPerPixel() / 8;

for (int y=0; y<image.getHeight(); y++) {
    
    for (int x=0; x<image.getWidth(); x++) {
        
        int index = components * (x + image.getWidth() * y);
        int red = data[ index ];
        int green = data[ index + 1 ];
        int blue = data[ index + 2 ];
        
        cout << "Pixels: " << red << " " << green << " " << blue << endl;
    }
}

NOTE: here are the images I’m using where I see the problem LINK 1 WORKS and LINK 2 DOES NOT

To go further here are the printed out properties I find when running the ‘file’ command in terminal on MAC:

LINK 1 IMAGE
file moon1.jpg
moon1.jpg:
JPEG image data, JFIF standard 1.01,
resolution (DPI), density 72x72, segment length 16,
Exif Standard: [TIFF image data, big-endian, direntries=0],
comment: “NASA false color moon mosaic retouched by Kevin N. Haw, http://www.theHaws.org, to remove alia”, baseline, precision 8, 2600x2910, frames 3

LINK 2 IMAGE
file landscape.jpg
landscape.jpg:
JPEG image data, JFIF standard 1.01,
resolution (DPI), density 300x300, segment length 16,
comment: “File source: https://commons.wikimedia.org/wiki/File:RUS-2016-Aerial-SPB-Tauride_Palace_(crop)”, baseline, precision 8, 1920x1233, frames 3

If you want more details (from identify -verbose file.jpg)

Image: Moon_Crescent_-_False_Color_Mosaic.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 2600x2910+0+0
  Resolution: 72x72
  Print size: 36.1111x40.4167
  Units: PixelsPerInch
  Colorspace: sRGB
  Type: TrueColor
  Base type: Undefined
  Endianess: Undefined
  Depth: 8-bit
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Pixels: 7566000
    Red:
      min: 0  (0)
      max: 255 (1)
      mean: 86.2056 (0.338061)
      standard deviation: 85.2383 (0.334268)
      kurtosis: -1.47816
      skewness: 0.289432
      entropy: 0.687978
    Green:
      min: 0  (0)
      max: 255 (1)
      mean: 64.4268 (0.252654)
      standard deviation: 66.9627 (0.262599)
      kurtosis: -1.06492
      skewness: 0.515134
      entropy: 0.682274
    Blue:
      min: 0  (0)
      max: 255 (1)
      mean: 53.8319 (0.211105)
      standard deviation: 55.524 (0.217741)
      kurtosis: -1.08764
      skewness: 0.504379
      entropy: 0.662407
  Image statistics:
    Overall:
      min: 0  (0)
      max: 255 (1)
      mean: 68.1547 (0.267274)
      standard deviation: 69.2417 (0.271536)
      kurtosis: -0.949414
      skewness: 0.575857
      entropy: 0.677553
  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)
  Matte color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 2600x2910+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 100
  Orientation: Undefined
  Properties:
    comment: NASA false color moon mosaic retouched by Kevin N. Haw, http://www.theHaws.org, to remove aliasing for Wikipedia.
    date:create: 2018-02-28T18:36:19+01:00
    date:modify: 2018-02-28T18:36:14+01:00
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x2,1x1,1x1
    signature: 1078d82c3efed3c356b268b773ca2e5e9e942ec8bf1676ab3edf6dabc9b031aa
  Profiles:
    Profile-exif: 9018 bytes
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 2.55973MiB
  Number pixels: 7566000
  Pixels per second: 75660000B
  User time: 0.090u
  Elapsed time: 0:01.099
  Version: ImageMagick 7.0.7-23 Q16 x86_64 2018-02-19 http://www.imagemagick.org

and

Image: RUS-2016-Aerial-SPB-Tauride_Palace_(crop).jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 1920x1233+0+0
  Resolution: 300x300
  Print size: 6.4x4.11
  Units: PixelsPerInch
  Colorspace: sRGB
  Type: TrueColor
  Base type: Undefined
  Endianess: Undefined
  Depth: 8-bit
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Pixels: 2367360
    Red:
      min: 0  (0)
      max: 255 (1)
      mean: 101.489 (0.397997)
      standard deviation: 60.9987 (0.239211)
      kurtosis: -0.869175
      skewness: 0.313304
      entropy: 0.975755
    Green:
      min: 0  (0)
      max: 255 (1)
      mean: 109.328 (0.428739)
      standard deviation: 59.3836 (0.232877)
      kurtosis: -0.863575
      skewness: 0.285436
      entropy: 0.976854
    Blue:
      min: 0  (0)
      max: 255 (1)
      mean: 99.1012 (0.388632)
      standard deviation: 55.8651 (0.219079)
      kurtosis: -0.561279
      skewness: 0.474425
      entropy: 0.963098
  Image statistics:
    Overall:
      min: 0  (0)
      max: 255 (1)
      mean: 103.306 (0.405123)
      standard deviation: 58.7492 (0.230389)
      kurtosis: -0.77732
      skewness: 0.354376
      entropy: 0.971902
  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)
  Matte color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 1920x1233+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 80
  Orientation: Undefined
  Properties:
    comment: File source: https://commons.wikimedia.org/wiki/File:RUS-2016-Aerial-SPB-Tauride_Palace_(crop).jpg
    date:create: 2018-02-28T18:35:40+01:00
    date:modify: 2018-02-28T18:35:40+01:00
    icc:copyright: Copyright 1999 Adobe Systems Incorporated
    icc:description: Adobe RGB (1998)
    icc:manufacturer: Adobe RGB (1998)
    icc:model: Adobe RGB (1998)
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x2,1x1,1x1
    signature: 155d58a411d45ac777adc39b5392576a26c57d575ff9f49d9f5e026df9574c38
  Profiles:
    Profile-icc: 560 bytes
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 902420B
  Number pixels: 2367360
  Pixels per second: 78.912MB
  User time: 0.040u
  Elapsed time: 0:01.029
  Version: ImageMagick 7.0.7-23 Q16 x86_64 2018-02-19 http://www.imagemagick.org

The first one uses profile exif, the second one profile icc. No idea if it’s related. Maybe removing metadata helps? Also, the first one is even number of pixels, the second one odd.

Interesting, so initially I ran into the issue because I pulled THIS IMAGE off a hashtag.

When I download that image as well, and run it through OF ofImage, I get the same issue listed above.

On another note I tried the same in processing and it works fine. What could be different about the way OF gets pixels from images as opposed to Processing???

identify -verbose test.jpg

Image: test.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 640x640+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: 409600
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 86.3825 (0.338755)
      standard deviation: 70.5677 (0.276736)
      kurtosis: -0.0862971
      skewness: 1.06328
      entropy: 0.904914
    Green:
      min: 0 (0)
      max: 254 (0.996078)
      mean: 72.921 (0.285965)
      standard deviation: 63.5891 (0.249369)
      kurtosis: 0.0005833
      skewness: 1.08913
      entropy: 0.888557
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 70.1646 (0.275155)
      standard deviation: 60.9888 (0.239172)
      kurtosis: 0.563489
      skewness: 1.271
      entropy: 0.900114
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 76.4894 (0.299958)
      standard deviation: 65.1741 (0.255585)
      kurtosis: 0.293139
      skewness: 1.17593
      entropy: 0.897861
  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: 640x640+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 80
  Orientation: Undefined
  Properties:
    date:create: 2018-02-28T15:06:42-05:00
    date:modify: 2018-02-28T15:06:16-05:00
    icc:name: c2
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x2,1x1,1x1
    signature: 63c35a18f2c950baf12b216f1bdff5b0179e4591cd71a1e74d0bc04711c4556a
  Profiles:
    Profile-8bim: 108 bytes
    Profile-icc: 524 bytes
    Profile-iptc: 95 bytes
      Special Instructions[2,40]: FBMD23000986030000411d0000a52400000b2c000045520000a369000004760000139a000073b10000a7c00000
  Artifacts:
    filename: test.jpg
    verbose: true
  Tainted: False
  Filesize: 49.3KB
  Number pixels: 410K
  Pixels per second: 136.53GB
  User time: 0.000u
  Elapsed time: 0:01.000
  Version: ImageMagick 6.9.1-0 Q16 x86_64 2015-03-22 http://www.imagemagick.org