skip to Main Content

I have an Illustrator, a PNG image and an SVG file with a box filled with #041C2C color (a dark blue).
When I’m trying to export any of these files to jpg, the image result change a little bit the red value and alter the color to #051c2c.

I used Illustrator, Photoshop, Sketch and InVision Studio with different export settings. I also tried and online jpg generator but the downloaded image always shows the wrong color when I opened it back.
In Photoshop I play with color profiles but nothing good happens.

Can any of you replicate what I did but obtaining the correct color?

Is there a method to get the original color?

2

Answers


  1. You face several problems. One is the RBG color space used in PNG and the YCbCr colorspace used in JPEG do not have the same gamut. If you represent the RBG color space as a graph you get a cube of colors that can be represented. If you overlay the YCbCr color space you get another cube with a vertex at (0,0,0) but the cube is rotated.

    When you do an RBG to YCbCr conversion, values outside the YCbCr box get clamped to fit inside the box.

    Another is the JPEG process uses floating point arithmetic that results in rounding.

    Another is the quantization. You can avoid this one by using all 1s in your quantization able (and get poor compression).

    Login or Signup to reply.
  2. Such a color cannot be stored in the JPEG format.

    For the #041c2c color, the corresponding (R, G, B) values are (4, 28, 44).
    For the #051c2c color, the corresponding (R, G, B) values are (5, 28, 44).

    According to the JFIF standard, YCbCr colors (with 256 levels per component) can
    be computed directly from full scale 8-bit per color channel RGB colors as follows:

    Y  = Min(Max(0, Round(  0.299*R + 0.587*G + 0.114*B)), 255)                = Min(Max(0, Round(22.648)), 255)        = 23
    Cb = Min(Max(0, Round((-0.299*R - 0.587*G + 0.886*B) / 1.772 + 128)), 255) = Min(Max(0, Round(140.0496614)), 255)   = 140
    Cr = Min(Max(0, Round(( 0.701*R - 0.587*G - 0.114*B) / 1.402 + 128)), 255) = Min(Max(0, Round(114.699001427)), 255) = 115
    

    So the (Y, Cb, Cr) triplet is (23, 140, 115).

    The inverse relationship for computing full scale 8-bit per color channel RGB values from YCbCr colors
    (with 256 levels per component) can be computed as follows:

    R = Min(Max(0, Round(Y + 1.402 * (Cr - 128))), 255) = Min(Max(0, Round(4.774)), 255) = 5
    G = Min(Max(0, Round(Y - (0.114 * 1.772 * (Cb - 128) + 0.299 * 1.402 * (Cr - 128)) / 0.587)), 255) = Min(Max(0, Round(28.1541362862)), 255) = 28
    B = Min(Max(0, Round(Y + 1.772 * (Cb - 128))), 255) = Min(Max(0, Round(44.264)), 255) = 44
    

    As you can see, the (R, G, B) values are (5, 28, 44).

    No combination of YCbCr values leads to the (4, 28, 44) on the output.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search