#library #image-processing

lenna_core

Lenna is a library for image processing algorithms and apps

5 releases

0.2.0 Jan 2, 2022
0.1.9 Aug 15, 2021
0.1.3 Jul 25, 2021
0.1.1 Jun 22, 2021

#391 in Images

Download history 23/week @ 2023-10-28 6/week @ 2023-11-04 17/week @ 2023-11-11 9/week @ 2023-11-18 38/week @ 2023-11-25 23/week @ 2023-12-02 4/week @ 2023-12-09 14/week @ 2023-12-16 25/week @ 2023-12-23 2/week @ 2023-12-30 9/week @ 2024-01-06 7/week @ 2024-01-13 19/week @ 2024-01-20 22/week @ 2024-01-27 5/week @ 2024-02-03 38/week @ 2024-02-10

88 downloads per month
Used in lenna_cli

MIT license

3.5MB
1K SLoC

lenna-core

build Crates.io dependency status

Lenna is a library for image processing algorithms and apps.

This is the core library for lenna.

Lenna CLI

quickstart

cargo build

run tests

cargo test
cargo test --features=python
wasm-pack test --node

Build

create plugins

use image::DynamicImage;
use lenna_core::core::processor::Processor;
use lenna_core::plugins::PluginRegistrar;
use lenna_core::ImageProcessor;
use lenna_core::ExifProcessor;
use lenna_core::ProcessorConfig;

lenna_core::export_plugin!(register);

extern "C" fn register(registrar: &mut dyn PluginRegistrar) {
    registrar.add_plugin(Box::new(Plugin{ config: Config::default() }));
}
#[derive(Default, Clone, serde::Serialize, serde::Deserialize)]
struct Config {
}
#[derive(Clone)]
pub struct Plugin {
    config: Config
};
impl Processor for Plugin {
    fn name(&self) -> String {
        "plugin".into()
    }

    fn title(&self) -> String {
        "Plugin".into()
    }

    fn author(&self) -> String {
        "chriamue".into()
    }

    fn description(&self) -> String {
        "Plugin description.".into()
    }

    fn process(
        &mut self,
        config: ProcessorConfig,
        image: &mut Box<lenna_core::LennaImage>,
    ) -> Result<(), Box<dyn std::error::Error>> {
        self.config = serde_json::from_value(config.config).unwrap();
        self.process_exif(&mut image.exif).unwrap();
        self.process_image(&mut image.image).unwrap();
        Ok(())
    }

    fn default_config(&self) -> serde_json::Value {
        serde_json::to_value(Config::default()).unwrap()
    }
}
impl ImageProcessor for Plugin {
    fn process_image(
        &self,
        image: &mut Box<DynamicImage>,
    ) -> Result<(), Box<dyn std::error::Error>> {
        let img = DynamicImage::ImageRgba8(image.to_rgba8());
        *image = Box::new(img);
        Ok(())
    }
}
impl ExifProcessor for Plugin {}

🐍 build python bindings

Create a virtual environment for python and install lenna-core using pip.

virtualenv -p python3 .venv
source .venv/bin/activate
pip install .
python src/plugins/python/test.py
import lenna_core_py
print(lenna_core_py.Resize.description())

🌏 Language Support

Rust Rust JavaScript JavaScript Python Python C++ C++ WASM WASM
Yes Yes Yes No Yes

📜 License

This software is licensed under the MIT © lenna-project.

Dependencies

~18MB
~172K SLoC