Skip to content

BUG: Weird result when saving matrix to png file #1067

@IoachimusRoderici

Description

@IoachimusRoderici

I have stored an image in a Matrix{RGB24}.

When i save the image to a jpg file, i get the expected result. When i save the image to a png file, it looks very wrong.

I am using Julia v1.11.3 and Images v0.26.2.

Minimal Working Example:

using Images, ColorTypes

# Fill a matrix with 4 random colors:
image = zeros(RGB24, 100,100)
image[1:50,1:50] .= RGB24(1, 1, 1)
image[50:100,50:100] .= RGB24(1, 0.7, 0.5)
image[1:50,50:100] .= RGB24(0.32, 0.9, 0.01)
image[50:100,1:50] .= RGB24(0.85, 0.52, 0.1)

# Save to jpg and png:
save("image.jpg", image)
save("image.png", image)

image.jpg (looks ok):

Image

image.png (looks wrong):

Image


EDIT: Better example

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions