-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Use enums for Modes and RawModes in C #9100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Would you mind writing up an explanation for why this is helpful? |
One of the things that I'd like to do here is move (almost) all of this stuff from
The only thing here that can't be in the mode struct and static per mode is the linesize.
So that gains us a lot less complexity in (depending on the metadata standard) I'm hoping that we could statically generate the arrow mode metadata and store it there as well. This would work if it's just mode based, but it's less useful if it's going to include image specific metadata, like sizes. |
@eyedav I've got updates that fix the compilation errors and pass the tests here: https://github.com/wiredfool/Pillow/tree/mode_enums . I can't see how to make a PR or push against your repo -- there should be a setting somewhere to allow admins to push to this branch that you can enable. |
@wiredfool the setting to allow maintainers to push to this branch was actually already enabled, I just tried to uncheck and check it again a moment ago. Could you please try a second time? Otherwise, as a workaround I could temporarily add you as collaborator to my fork. |
@eyedav I've tried again with no luck. If you can add me I'd appreciate it. |
[IMAGING_MODE_RGBa] = {"RGBa"}, [IMAGING_MODE_YCbCr] = {"YCbCr"}, | ||
|
||
[IMAGING_MODE_BGR_15] = {"BGR;15"}, [IMAGING_MODE_BGR_16] = {"BGR;16"}, | ||
[IMAGING_MODE_BGR_24] = {"BGR;24"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BGR;* modes (but not rawmodes) were removed in #9053
src/libImaging/Pack.c
Outdated
{IMAGING_MODE_I_16N, IMAGING_RAWMODE_I_16N, 16, copy2}, | ||
{IMAGING_MODE_I_16, IMAGING_RAWMODE_I_16N, 16, packI16N_I16 | ||
}, // LibTiff native->image endian. | ||
{IMAGING_MODE_I_16, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actively bad formatting, destroying all of the symmetry of the lines above and below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added more changes to rearrange the code.
from setuptools import Extension, setup | ||
from setuptools.command.build_ext import build_ext | ||
|
||
if TYPE_CHECKING: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skip the import:
if TYPE_CHECKING: | |
TYPE_CHECKING = False | |
if TYPE_CHECKING: |
import sys | ||
import warnings | ||
from collections.abc import Iterator | ||
from typing import TYPE_CHECKING |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from typing import TYPE_CHECKING |
Rebase of PR #8510 (Use enums for Modes and RawModes in C) on latest main, done during EuroPython25's Sprint: creating a new PR as agreed with @wiredfool.