Best way to resize / convert images?

I’m working on an Arduino Mopidy client display. The goal is a wall clock that shows the current songs playing. It’s based on an ESP32 with a 64x64 LED display. I’ve got it querying the server using WebSockets and displaying playing track information.

I’d like to show scaled album artwork on the display. I’ve got Mopidy-Local-Images working and can query for images from the database.

But, the ESP32 has very little working memory and minimal processing power. I’d like to have the images converted to 64x64 .png files on the raspberry pi that is hosting my mopidy server.

I’ve thought of using katana, an image proxy, but it has a lot of depends and may be overkill and still not do what I need.

Is there a proxy server that makes sense or would it be easier to modify the Mopidy-Local-Images code to do this? Have others had to deal with this already?

Thanks,
Rudy

Here is a diff that modifies library.py in mopidy-local-images to have it save a second, 64x64, .png copy of each image and add that image to the library. Scripts can then call for that smaller version if they wish… It does require the PIL library.

Note: I don’t know Python. So I might be breaking some obvious rules. But it seems to work well. This totally makes me want to learn Python.

Rudy

1,4d0
<
<       mopidy-local-images/mopidy_local_images/library.py
<
<
20a17,18
> from PIL import Image
>
161a160
>                     print(uritools.urijoin(self.base_uri, name))
181c180
<                 images.add(self._get_or_create_image_file(None, data))
---
>                 images = images.union(self._get_or_create_image_file(None, data))
190c189
<                     images.add(self._get_or_create_image_file(path))
---
>                     images = images.union(self._get_or_create_image_file(path))
214a214
>         namepng = '%s.tiny.png' % (digest)
215a216
>         destpng = os.path.join(self.image_dir,namepng)
220c221,232
<         return uritools.urijoin(self.base_uri, name)
---
>         # file is written. Can I reload it with the Image class and then resize it?
>         size = (64, 64)
>         im = Image.open(dest)
>         im.thumbnail(size)
>         im.save(destpng)
>
>         # now we want to return the set of both files
>         both = set()
>         both.add(uritools.urijoin(self.base_uri, name))
>         both.add(uritools.urijoin(self.base_uri, namepng))
>
>         return both