Open Graphic Image Writer

Overview

Open Graphic Image Writer

Documentation

You can generate Open Graphic Image dynamically.

  • A CSS-like API.
  • You can generate image by using template image.

Problem

Currently, when you want to create OGP image dynamically, you may use canvas. But to use canvas, you need to open a browser and run some script. This is overhead, especially if you are using feature like the SSG. Therefore this lib is targeting a high performance API for all platform by using wasm.

Example

For more examples, see keiya01/og_image_writer/examples.

use og_image_writer::{style, writer::OGImageWriter};
use std::io;

fn main() -> io::Result<()> {
    let text = "This is Open Graphic Image Writer for Web Developer.";

    let mut writer = OGImageWriter::new(style::WindowStyle {
        width: 1024,
        height: 512,
        background_image: Some("./examples/assets/og_template.png"),
        align_items: style::AlignItems::Center,
        justify_content: style::JustifyContent::Center,
        ..style::WindowStyle::default()
    });

    writer.set_text(
        text,
        style::Style {
            margin: style::Margin(0., 20., 0., 20.),
            line_height: 1.8,
            font_family: "YuGothic",
            font_size: 50.,
            font_style: style::FontStyle::Normal,
            font_weight: style::FontWeight::Bold,
            word_break: style::WordBreak::Normal,
            color: style::RGB(1., 1., 1.),
            text_align: style::TextAlign::Start,
            ..style::Style::default()
        },
    );

    let out_dir = "./examples/assets";
    let out_filename = "output_background_image.png";

    writer.generate(&format!("{}/{}", out_dir, out_filename))?;

    Ok(())
}

When you pass the following the template image,

example template image

this code generate the following image.

example output image

And you can also set background-color instead of passing the template image.

For more examples, see keiya01/og_image_writer/examples.

You might also like...
A simple command-line utility (and Rust crate!) for converting from a conventional image file (e.g. a PNG file) into a pixel-art version constructed with emoji
A simple command-line utility (and Rust crate!) for converting from a conventional image file (e.g. a PNG file) into a pixel-art version constructed with emoji

EmojiPix This is a simple command-line utility (and Rust crate!) for converting from a conventional image file (e.g. a PNG file) into a pixel-art vers

A Simple Image to Ascii converter in Rust
A Simple Image to Ascii converter in Rust

Image to Ascii A Simple Image to Ascii converter in Rust Brief 📖 In my way to learn Rust i decided to make this converter. Challenges 🐢 new to Rust

Rust library for fast image resizing with using of SIMD instructions.

fast_image_resize Rust library for fast image resizing with using of SIMD instructions. CHANGELOG Supported pixel formats and available optimisations:

Experimental vectorized-raster image editor

Sverg Sverg is an experimental image editor that leverages the power of modern hardware so that you can create images as if they were raster images (e

Rust port of the Quite Okay Image format

qoi_rs What is this? A pretty boring Rust translation of qoi. Status What's there Encode & Decode works Results agree with the C implementation for al

A Rust encoder/decoder for Dominic Szablewski's QOI format for fast, lossless image compression.

QOI - The “Quite OK Image” format This is a Rust encoder and decoder for Dominic Szablewski's QOI format for fast, lossless image compression. See the

An advanced image processing library for Rust.

ImageProc Maintainers: @chyh1990 Note: this project is under active depvelopment, API may change! imageproc is a advanced image proccessing library fo

Web-app that simulates different types of color blindness from a user-provided input image.

What is Dalted? Web-app that simulates different types of color blindness from a user-provided input image. Resources The color blindness simulation i

Get the first frame of a Gif image.

Gif First Frame Use wasm to capture the first frame of a Gif image.

Comments
  • Why The Cargo Workspace?

    Why The Cargo Workspace?

    Cargo crates support having a standalone examples folder within them which can be run via cargo run --example foo. In that case, it would run examples/foo.rs or examples/foo/mod.rs. You would still be able to use your og_image_writer main crate just by doing use og_image_writer so no code changes required as I see it.

    opened by sno2 2
  • feat: support wasm runtime

    feat: support wasm runtime

    og_image_writer was supporting only wasm for web. But in a lot of case like fastly compute@edge, wasm runtime like wasmtime is used. Also wasm that is using wam-bindgen does not work on wasmtime. So I fixed to separate wasm to wasm for web and wasm for wasm runtime.

    opened by keiya01 1
  • Public-facing Error Handling

    Public-facing Error Handling

    Hello, I think it would be great if users could handle errors themselves in which we created a Error and return Result<_, Error> instead of unwrapping in the code. I am willing to contribute this via this_error if you would like.

    opened by sno2 1
  • Package the WASM compilation for Node?

    Package the WASM compilation for Node?

    Hi @keiya01! I just found your og_image_writer crate, and it seems to do exactly what I need! I was just wondering if you had considered creating a WASM version compiled with the Node target, and publishing it to npm, to make it a bit easier for people to import. Happy to submit that as a PR, or if you'd prefer, to fork and maintain that separately. I'm also curious about a napi-rs version!

    opened by benwis 3
Owner
keiya sasaki
keiya sasaki
Lust is a static image server designed to automatically convert uploaded image to several formats and preset sizes

What is Lust? Lust is a static image server designed to automatically convert uploaded image to several formats and preset sizes with scaling in mind.

Harrison Burt 242 Dec 22, 2022
Takes a folder of images (as a palette), and an image, and figures out how to tile the palette to resemble the image!

Takes a folder of images (as a palette), and an image, and figures out how to tile the palette to resemble the image!

Jacob 258 Dec 30, 2022
Rust Lean Image Viewer - Fast and configurable image viewer inspired by JPEGView by David Kleiner

Rust Lean Image Viewer - Fast and configurable image viewer inspired by JPEGView by David Kleiner

3top1a 4 Apr 9, 2022
Image processing operations

imageproc An image processing library, based on the image library. There may initially be overlap between the functions in this library and those in i

image-rs 512 Jan 8, 2023
Image Compression Algorithm

Image Compression Algorithm ?? A new lossless image compression algorithm. In the newest version the algorithm performs rather good, but manages to su

Hannes 31 May 10, 2022
tai (Terminal Ascii Image) tool to convert images to ascii written in Rust

TAI Terminal Ascii Image A tool to convert images to ascii art written in Rust ?? Notes This tool is still in development stage. Contributions All Con

Mustafa Salih 258 Dec 5, 2022
Artsy pixel image to vector graphics converter

inkdrop inkdrop is an artsy bitmap to vector converter. Command line interface The CLI binary is called inkdrop-cli and reads almost any image bitmap

Matthias Vogelgesang 62 Dec 26, 2022
Automated image compression for efficiently distributing images on the web.

Imager Apparently this project made it into the GitHub Archive Program. About Imager is a tool for automated image compression, and can competitively

Imager IO 487 Dec 25, 2022
Signed distance field font and image command line tool based on OpenCL.

SDFTool Signed distance field font and image command line tool based on OpenCL. Build Windows Run cargo build --release in Visual Studio developer x64

弦语蝶梦 7 Oct 16, 2022
A simple image average color extractor written in 🦀 Rust

A simple image average color extractor written in ?? Rust

Victor Aremu 3 Sep 23, 2021