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

Transparency not preserved on Windows. #5

Closed
Bertz-TII opened this issue Feb 22, 2024 · 7 comments
Closed

Transparency not preserved on Windows. #5

Bertz-TII opened this issue Feb 22, 2024 · 7 comments

Comments

@Bertz-TII
Copy link

Hi,

first of all thank you for this awesome library - I have been looking for something like this for ages. Copying images to the clipboard works great, but image transparency is unfortunately lost (in my testing on Windows 11). My images are matplotlib renders and I am doing something like this.

with io.BytesIO() as f:
    # fig is a matplotlib figure
    fig.savefig(f, format='png', transparent=True)
    with Image.open(f) as image:
        pixels = image.tobytes()
        copykitten.clear()
        copykitten.copy_image(pixels, image.width, image.height)

image is RGBA as reported by PIL. Saving the image to disk using image.save('test.png') works fine and preserves transparency.
Please let me know if I am doing anything wrong.

Cheers & many thanks

@Klavionik
Copy link
Owner

Hey, congrats on the first issue in this repository. :)

Windows is indeed tricky when it comes to image transparency. Though, I tried to reproduce this issue and didn't succeed. I may need more details. What program do you paste the image into?

@Bertz-TII
Copy link
Author

Hi,

I am pasting into PowerPoint for windows.
As an aside, everything works flawlessly in macOS using the same code...

@Klavionik
Copy link
Owner

Thank you, this time I was able to reproduce the issue. It's safe to assume that this is an issue with arboard, not with copykitten itself.

The thing is, AFAIK, the Windows clipboard image formats are no good when it's about transparency. The one workaround here is to put image data into the clipboard as a PNG file (this is what Chrome does, for example).

That being said, I'll try and see what I can do about it. Maybe I can contribute support for such a workaround to arboard (if the maintainers are willing to accept this solution).

@Bertz-TII
Copy link
Author

Thanks for the heads-up. Being able to put files of a specific format (like a MIME type?) onto the clipboard would be a great addition and open the possibility to use vector formats as well...

Please let me know if I can be of any help.

@Klavionik
Copy link
Owner

@Bertz-TII There's a new release v1.2.0 in which this issue should be fixed. Try it out and let me know if it works for you.

@Bertz-TII
Copy link
Author

Works like a charm, thank you very much!

@Klavionik
Copy link
Owner

Happy to hear it! I'm closing the issue then. :)

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

No branches or pull requests

2 participants