Skip to content
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

Add functions to Image: static fromqimage and fromqpixmap; methods toqimage and toqpixmap #897

Closed
rominf opened this issue Sep 12, 2014 · 6 comments
Milestone

Comments

@rominf
Copy link
Contributor

rominf commented Sep 12, 2014

I'm writing Qt application that needs diff feature of Pillow Image. So, I need to convert QPixmap to Image and and vice versa.

I've found existing class ImageQt. But I don't like it. It contains just one __init__ function. In this case using class is not required. I would say it's misleading.

I'm gonna prepare functions for Image class: static fromqimage and fromqpixmap; methods toqimage and toqpixmap.

Those functions would be defined only if PyQt is installed.

What do you think?

PS: I would like to change from* functions to from_* due readability. But I want to be consistent. If you like from* more, I would write fromqpixmap, etc.

@wiredfool
Copy link
Member

I think that they'd probably be better off in the ImageQt module.

The ImageQt class is essentially a class based version of toqimage. Apparently it used to wrap rather than extend QImage. I'm not clear on the reasoning behind that, being 8 years ago and not familiar with PyQT code styles.

It seems reasonable to have to/from versions for converting between PIL.Images and QImages and QPixmaps.

For better or worse, the current style on to/from is smushed words, not _ words.

@rominf
Copy link
Contributor Author

rominf commented Sep 13, 2014

I'm using PyQt for a long time. There is no reason to subclass QImage in this case.

I understand your intent to separate Qt specific code from anything else. I will put everything related Qt into separate file qt.py (or ImageQt.py if you want) and then, in the image.py I will put:

import qt
if qt.is_installed:
    from qt import fromqimage, toqimage, fromqpixmap, toqpixmap

@aclark4life
Copy link
Member

Looks like this was shipped in 2.7.0

@hugovk
Copy link
Member

hugovk commented Mar 26, 2015

It wasn't shipped in 2.7.0: its PR is still open but not ready for merge.
#905

@aclark4life
Copy link
Member

Thanks

@radarhere
Copy link
Member

This change has been merged with PR #1217 and so this issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants