brndnmtthws / conky

Light-weight system monitor for X, Wayland (sort of), and other things, too
https://conky.cc
GNU General Public License v3.0
7.31k stars 620 forks source link

Need Imlib2 alternative for Wayland #1845

Open Caellian opened 7 months ago

Caellian commented 7 months ago

Imlib2 doesn't work for Wayland because it requires X11. As we provide bindings to Imlib2 for Lua, we need to find an alternative that's similar in functionality for Wayland.

Imlib2 supports following features:

  • Load image files from disk in one of many formats
  • Save images to disk in one of many formats
  • Render image data onto other images
  • Render images to an X-Windows drawable
  • Produce pixmaps and pixmap masks of Images
  • Apply filters to images
  • Rotate images
  • Accept RGBA Data for images
  • Scale images
  • Alpha blend Images on other images or drawables
  • Apply color correction and modification tables and factors to images
  • Render images onto images with color correction and modification tables
  • Render truetype anti-aliased text
  • Render truetype anti-aliased text at any angle
  • Render anti-aliased lines
  • Render rectangles
  • Render linear multi-colored gradients
  • Cache data intelligently for maximum performance
  • Allocate colors automatically
  • Allow full control over caching and color allocation
  • Provide highly optimized MMX assembly for core routines
  • Provide plug-in filter interface
  • Provide on-the-fly runtime plug-in image loading and saving interface
  • Fastest image compositing, rendering and manipulation library for X

Not sure if such a thing exists even. So this is an open ended question - let me know if you know of any.

Direct Wayland support isn't really a hard requirement though. It seems these days libraries tend to be much smaller in scope (which is a good thing ig), so we might end up having to combine multiple different libraries:

I can't find which formats Imlib2 supports, but Imlib supports PPM, PGM, TIFF, PNG, XPM, JPEG and EIM, so I guess maybe a few more. Most images these days come in PNG, JPEG, BMP and WebP, so I guess those are a good starting place. Loader for BMP format can probably be copied from SO bc it's simple.

Important detail to keep in mind is that image loading and manipulation are very susceptible to arbitrary (malicious) code execution, so any work on this has to be triple-checked.

Caellian commented 7 months ago

A good option in Rust would be image-rs/image and it supports a lot of formats. But it comes without C bindings, so we'd need to write those... and add Rust to build requirements.

The up sides are:

We can use cbindgen by mozilla (if that means "stable") to generate bindings, but we'd still need to write C API wrapper.

Caellian commented 7 months ago

According to this mailing list from enlightenment, the author of Imlib2 discontinued work on it and started a separate project that does the same: efl/evas. It supports Wayland and does some things better than Imlib2.

Conan-Kudo commented 4 months ago

Another option is SDL2_image maybe?

Caellian commented 4 months ago

Another option is SDL2_image maybe?

SDL2 is a huge dependency (4.4MB; entire Conky is ~11MB) which is why I didn't mention it. It would be nice to use it, but sadly SDL2_image returns loaded images in SDL_Surface struct which is part of the parent library.