Basquiat is a CLI tool that performs batch image resizing operations and returns an ipfs CID that links to the original, with metadata pointing to all generated versions using a general-purpose schema.
See here.
To install rustup on Linux or MacOS
$ curl https://sh.rustup.rs -sSf | sh
The libvips
library needs to be installed :
On mac os
brew install libvips`
On Ubuntu
apt-get install libvips
$ git clone git@github.com:fission-suite/basquiat.git
$ cd basquiat
$ ipfs daemon > ipfsd_log.txt #The ipfs daemon must be running!
$ cargo run -q -- <path_to_image>
cargo run
builds and runs in one command. You can always find the executable
at target/debug/basquiat
.
By default, a simple html page presents a list of the available versions at <root_cid>/thumbnails.html
. This feature
can be disabled by a flag as detailed in the command's --help
message.
The root CID points to the original version with named links to other sizes.
A given size WxH.jpg
has its CID linked to three times by the root node :
_xH.jpg
Wx_.jpg
WxH.jpg
W
and X
are integers in pixel units.
This schema can be subsequently expanded to include transformations other than rescaling,
using an expandable syntax. For a given operation c
, with parameters A
and B
,
an operation on the given size WxH.jpg
will also be linked to three times:
_xH.c-A-B.jpg
Wx_.c-A-B.jpg
WxH.c-A-B.jpg
This syntax is expandable to a sequence of operations by further concatenation.
For instance, the following could represent a file resized to a certain height H
,
then cropped from the top (operation ct
) to a certain height Hp
then cropped from the left (cl
) to a
certain width Wp
:
_xH.ct-Hp.cl-Wp.jpg
This specification will also be used to configure iimir.
- When original file size is too small, its data gets overwritten in the output dag by a smaller version. This is due to a documented go-ipfs issue.