Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I'm trying to copy part of a large canvas onto a smaller canvas. I had been doing this by retrieving the image data from the first canvas, at the required location, using "get_image_data" and then writing it to the smaller canvas with "put_image_data", as shown below:

image_data = canvas.get_image_data(x=0, y=0, width=64, height=64)
canvas2 = Canvas(width=64, height=64)   
canvas2.put_image_data( image_data, 0, 0 )

This was working, but now seems to be broken and I'm now getting an error "cannot write mode RGBA as JPEG".

The image loaded onto the first canvas is a PNG, so does have a transparency channel and I can put the image data onto the new canvas if I drop this channel (image_data[:,:,:3]) - but I'd like to keep the transparency.

So, is there another way that I can copy a section from a large canvas to a smaller one, or put image data while retaining the transparency?

You must be logged in to vote

Replies: 1 comment · 1 reply

Comment options

Thanks!

This looks like an issue with the latest ipycanvas release. You might fix it by downgrading ipycanvas to 0.11 for now.

I just opened an issue for that https://github.com/martinRenou/ipycanvas/issues/272

You must be logged in to vote
1 reply
@WhatIThinkAbout
Comment options

Thanks. Although I seem to be getting blank canvases returned when I downgrade to 0.11 - probably some dependency issue.
It's ok though, I can work around this for now, until it gets fixed, by manually slicing my large image in an image editor,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
💬
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.