-
Notifications
You must be signed in to change notification settings - Fork 50
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
Convenience methods for Pillow integration #486
Comments
Hi @jonashaag, sure this sounds useful. What would it add over going via numpy? |
Probably nothing on the technical side, just a few convenience methods. |
It should be pretty easy right now: import PIL.Image
pil_image = PIL.Image.new('RGB', (60, 30), color = 'red')
image = pyvips.Image.new_from_array(pil_image) and: import pyvips
import PIL.Image
image = pyvips.Image.black(100, 100, bands=3)
pil_image = PIL.Image.fromarray(image.numpy()) I don't know what PIL does with image metadata, maybe there's a simple way to bring that over as well? |
You're right that it's already quite simple... my suggestion of def pil(self):
try:
from PIL import Image
except ModuleNotFoundError as e:
raise ModuleNotFoundError("Pillow must be installed") from e
return Image.fromarray(self.numpy()) Honestly not sure anymore if it's worth adding this because it's a very thin wrapper... |
Proposal: Add convenience integration with PIL/Pillow, eg. converting back and forth. Something along the lines of
and
Happy to contribute a first draft if this is accepted.
The text was updated successfully, but these errors were encountered: