Okmain: How to pick an OK main colour of an image

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
sponsored
  1. saferimg

    saferimg decodes images using disintegration/imaging, but performs optional safety checks first

    As a designer, I've built variants of this several times throughout my career.

    The author's approach is really good, and he hits on pretty much all the problems that arise from more naive approaches. In particular, using a perceptual colorspace, and how the most representative colour may not be the one that appears the most.

    However, image processing makes my neck tingle because there are a lot of footguns. PNG bombs, anyone? I feel like any library needs to either be defensively programmed or explicit in its documentation.

    The README says "Finding main colors of a reasonably sized image takes about 100ms" -- that's way too slow. I bet the operation takes a few hundred MB of RAM too.

    For anyone that uses this, scale down your images substantially first, or only sample every N pixels. Avoid loading the whole thing into memory if possible, unless this handled serially by a job queue of some sort.

    You can operate this kind of algorithm much faster and with less RAM usage on a small thumbnail than you would on a large input image. This makes performance concerns less of an issue. And prevents a whole class of OOM DoS vulnerabilities!

    As a defensive step, I'd add something like this https://github.com/iamcalledrob/saferimg/blob/master/asset/p... to your test suite and see what happens.

  2. SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  3. colorhull

    Generate color themes from images

    This is nice! I looked into this quite a lot some years back when I was trying to summarize IKEA catalogs using color and eventually wrote an R package if you want to look into an alternative to e.g. k-means: https://github.com/lemonad/colorhull (download https://github.com/lemonad/ikea-colors-through-time/blob/mas... for more details on how it works)

  4. ikea-colors-through-time

    IKEA colors through time

    This is nice! I looked into this quite a lot some years back when I was trying to summarize IKEA catalogs using color and eventually wrote an R package if you want to look into an alternative to e.g. k-means: https://github.com/lemonad/colorhull (download https://github.com/lemonad/ikea-colors-through-time/blob/mas... for more details on how it works)

  5. image

    Encoding and decoding images in Rust (by image-rs)

    Author here: the library just accepts RGB8 bitmaps, probably coming either from Rust's image crate [1] or Python's Pillow [2], which are both mature and widely used. Dealing with codecs is way out of scope.

    As for loading into memory at once: I suppose I could integrate with something like libvips and stream strips out of the decoded image without holding the entire bitmap, but that'd require substantially more glue and complexity. The current approach works fine for extracting dominant colours once to save in a database.

    You're right that pre-resizing the images makes everything faster, but keep in mind that k-means still requires a pretty nontrivial amount of computation.

    [1]: https://crates.io/crates/image

    [2]: https://pypi.org/project/pillow/

  6. okmain

  7. homeassistantcomponent_spotifyplus

    Home Assistant integration for Spotify Player control, services, and soundtouchplus integration support.

  8. SpotifyWebApiPython

    A Spotify Web Api Client for Python

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Setting the DPI of an image before saving it

    1 project | /r/learnrust | 5 May 2023
  • Does the rust image crate support paletted png?

    1 project | /r/rust | 28 Feb 2023
  • picst - a CLI tool to resize clipboard images on the fly

    3 projects | /r/rust | 7 Nov 2022
  • From C# to Rust, what do i need to know?

    3 projects | /r/rust | 13 Sep 2022
  • Learn OpenGL with Rust: textures

    1 project | dev.to | 4 Sep 2022

Did you know that Rust is
the 3rd most popular programming language
based on number of references?