#image #exif #film #camera #camera-image #server-api

app rustant-film

Add a instant film style layout to your photo by EXIF

2 releases

new 0.1.1 Jan 18, 2025
0.1.0 Jan 18, 2025

#49 in Images

Apache-2.0

67KB
1.5K SLoC

rustant-film

Add an instant-film-style layout to your EXIF photos.

Samples

index layout image
1 Diagonal, pos left with paddings Image
2 Diagonal, pos right Image
3 Duel, pos left Image
4 Duel, pos right with paddings Image
6 Triangular, pos bottom with paddings Image
7 Triangular, pos bottom Image

Features

  • Written in Rust.
  • Provides both command line & server API.
  • Customizable logo & font.
  • Cross-platfrom by cargo.

Quick Start

To get rustant-film, use:

cargo install rustant-film

Or to build it from source:

cargo build --release

It's recommended to clone this repository and go through the next tutorial section.

Tutorial

To get some materials to develop a good image result, you should prepare your own fonts and logos. You can find a example material setup scripts in setup-example

Then run the following command to setup some essential meterials:

# You may need to install some commands used by the scripts, such as 'wget', 'unzip', and 'convert'.
sh ./setup-example/font.sh
sh ./setup-example/logo.sh
sh ./setup-example/sample.sh

This will generate example fonts, logos, and a sample photo under the ./resources directory.

Finally, run the following command:

rustant-film -i ./resources/samples -o ./output -f ./resources/font/ttf/FiraCode-SemiBold.ttf -l ./resources/logos

The output will be saved in the ./output directory.

For a more detailed guide on preparing media resources, refer to here.

Layouts

Currently, rustant-film supports the following layouts:

  • triangle: A traditional instant film layout with EXIF information displayed below.
  • blank: A raw instant film with only blank paddings, no extra info added.
  • duel: A layout with EXIF information displayed on left or right.
  • diagonal: A layout like duel by display EXIF information on top-left or bottom-right.
rustant-film -i ./resources/samples -o ./output -f ./resources/font/ttf/FiraCode-Regular.ttf -l ./resources/logos -p triangle

For a more classic instant film style, add padding around by using flag -pad:

rustant-film -i ./resources/samples -o ./output -f ./resources/font/ttf/FiraCode-Regular.ttf -l ./resources/logos -p triangle --pad

Some layout may use a sub-font to get a better look. To use a sub-font, use --sub-font:

rustant-film -i ./resources/samples -o ./output -f ./resources/font/ttf/FiraCode-SemiBold.ttf --sub-font ./resources/font/ttf/FiraCode-Regular.ttf -l ./resources/logos -p triangle --pad

Server

In addition to the command-line interface, rustant-film can also operate as an HTTP server. This allows you to generate and download files via RPC.

To run rustant-film in server mode, use the command like:

rustant-film -m server -f ./resources/font/ttf/FiraCode-SemiBold.ttf --sub-font ./resources/font/ttf/FiraCode-Regular.ttf

Once the server is running, you can send requests to the API. For example, to process an image, use the following curl command:

curl --output result.jpg 'http://0.0.0.0:6400/api/v1/develop?painter=diagonal&pad=false&pos=r' \
    -X POST \
    -H "Content-Type: multipart/form-data" \
    -F 'image=@./test.jpg'

This will generate and return the processed image as result.jpg.

Roadmap

rustant-film aims to implement the following features in future versions:

  • More Layout: Additional instant film layout options.
  • Adaptive Layout: Automatically adjusts the layout for photos with missing EXIF data.
  • Watermark: Adds watermarks, including invisible ones, to processed photos.
  • Copyright Support: Allows users to add custom copyright information, such as the artist's name, to the final photo.
  • Async HTTP API: Hosts the rustant-film command as an HTTP API server, providing asynchronous APIs.
  • GUI: Add a GUI for rustant-film, maybe as a new project.
  • Container Image: Distributes the rustant-film command-line tool and HTTP API as a container image.
  • Cargo Binary Publishing: Publishes the rustant-film command as a binary on crates.io.
  • Lens Logo Support: Some layouts may include lens logos.

Credit

Sample Fonts

  • "FiraCode" by Nikita Prokopov, used under OFL-1.1 license.

Sample Images

rustant-film will add instant film layout to the following images in showcase.

Dependencies

~22–31MB
~543K SLoC