What I’m trying to do:
I have an anvil web-app that I am running / developing on my laptop. On a Raspberry Pi I have an Anvil UpLink script that connects to the web-app.
The goal is for a user to press a button on the web-app which will call an anvil.uplink function to retrieve an image (currently 1 image, in the future up to 10) stored locally on the Raspberry Pi.
The Uplink function works correctly, however I am having trouble displaying the retrieved image.
What I’ve tried and what’s not working:
In the Anvil.Uplink function I have the follow code used to retrieve an image:
@anvil.server.callable
def get_image():
...
# Get image -> convert to anvil.BlobMedia object
anvil_image = anvil.media.from_file("path/to/image", "image/png")
print(anvil_image.get_bytes()) # prints long list of bytes
# Return Image
return anvil_image
On the client, side I have the following client code:
#call uplink Raspberry Pi function
retrieved_image = anvil.server.call("get_image")
#get & print dimensions of image:
width, height = anvil.image.get_dimensions(retrieved_image)
print(width)
print(height)
# Set visible to True
self.image_1.visible = True
#Set source to retrieved_image
self.image_1.source = retrieved_image
When I print the retrieved_image width & height I get the correct image height / width, so I am wondering if there is something wrong with the way I am trying to display it after I have retrieved it from the uplink function?
If there is any additional information I need / should provide, please let me know. The issue does not appear to be with Uplink. But rather with the way I am returning the image or with how I am trying to display it after I have retrieved it.
Thanks!