[issue45775] Implementation of colorsys.rgb_to_yuv and vice versa

Petr Viktorin report at bugs.python.org
Tue Nov 23 10:25:20 EST 2021


Petr Viktorin <encukou at gmail.com> added the comment:

> YUV is a common color encoding system. It's used by the JPEG image format and MPEG video format for example.

As far as I understand it, the YUV/RGB conversion used by JPEG is not the same as the one used by MPEG, and neither of those is the Rec 709 YUV proposed here.

YUV is used in video production and photography. If you need to work with it, you most likely need some kind of precise color matching. If colorsys implements the wrong one *for you* (even if it's the most commonly used one, and what HDTV uses), then the stdlib has failed you.

Meanwhile, RGB/HLS is used by Web designers writing CSS, GUI authors giving you a big green button to click, or color pickers for your avatar's hair. They're designing for uncalibrated monitors. *That* is the target audience for colorsys.
The image libraries these people use to read JPGs invariably convert to RGB and throw away any precise color information, which is meaningless on uncalibrated monitors.

I cannot see a use case for YUV in colorsys that doesn't also require a more complex image processing library. It's that library that should provide the necessary colorspace conversions, depending on if it's dealing with JPEG or MPEG or HDTV.

But please point out my mistakes and clear my doubts!

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45775>
_______________________________________


More information about the Python-bugs-list mailing list