Pillow icon indicating copy to clipboard operation
Pillow copied to clipboard

Add convert_mode param when saving

Open radarhere opened this issue 7 years ago • 3 comments

Resolves #2663

radarhere avatar Jun 10 '18 14:06 radarhere

We don't need to store a map of conversions for each file format. If format supports, for example, only RGB and image in CMYK, we always will do CMYK→ RGB conversion regardless of format. All we need to know is which modes are available for the desired file format. The convert_mode function should just convert from any of source modes to one of the available modes.

Moreover, we could add more internal modes from time to time without touching any plugins.

homm avatar Jun 30 '18 09:06 homm

Okay, I've added a commit. See what you think

radarhere avatar Jun 30 '18 12:06 radarhere

In general, this is great. The only drawback for me is binding of supported modes for the save function via the parent's module attribute. In particular, this prevents different sets of supported modes in one module. Isn't better to explicitly assign the supported modes to the save function?

def _save(im, fp, filename):
   pass

_save._supported_modes = ['RGB', 'RGBA', 'P', 'I', 'LA', 'L', '1']

homm avatar May 12 '19 15:05 homm