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

Need Imlib2 alternative for Wayland #1845

Open
Caellian opened this issue Apr 19, 2024 · 2 comments
Open

Need Imlib2 alternative for Wayland #1845

Caellian opened this issue Apr 19, 2024 · 2 comments
Labels
display: wayland Issue related to Wayland backend lua Issue or PR related to Lua code question Issue where reporter seeks information rendering Issue or PR related to rendering

Comments

@Caellian
Copy link
Collaborator

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:

  • A library for loading images.
    • Preferably one supporting multiple common formats at once.
    • Alternatively, 5/6 different libraries for each format.
  • A library that can do basic image processing.

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 Caellian added question Issue where reporter seeks information display: wayland Issue related to Wayland backend lua Issue or PR related to Lua code rendering Issue or PR related to rendering labels Apr 19, 2024
@Caellian Caellian added this to the Wayland Support milestone Apr 19, 2024
@Caellian
Copy link
Collaborator Author

Caellian commented Apr 19, 2024

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:

  • Rust is an NSA approved, superior, immaculate, irrefutable, sparkling, joyful and super-duper safe language.
  • The library supports most basic image manipulation operations.
  • It's fairly commonly used in rust ecosystem.

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

@Caellian
Copy link
Collaborator Author

Caellian commented Apr 23, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
display: wayland Issue related to Wayland backend lua Issue or PR related to Lua code question Issue where reporter seeks information rendering Issue or PR related to rendering
Projects
None yet
Development

No branches or pull requests

1 participant