'background color of JPG using wand (Python)

I use wand with Python to change the background color of a JPEG.

with Image(file=myJpg) as image:
    image.background_color = Color("#f0f0f0")
    image.save(filename='myJpg.jpg')

It seems to work because when I resize and extent image the background is filled with "#f0f0f0" (rgb(240,240,240)).

The image is a JPEG.

If I reload the image and get the background, it is white rgb(255,255,255):

with Image(file=myJpg) as img:
    assert img.background_color == Color("#f0f0f0")

The assertion is false. I don't understand why?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source