I tried digging into how save encodes an image and ran into this write_to function. It looks like save finds the file format with a match and encodes it to write to the specified path. Maybe, there is an API to do that to a buffer that I am not aware of.
Originally, I made this for a very specific need of the https://readbot.app project. I just needed to grayscale images (no color on kindle's e-ink display yet) and scale them down to 600 pixels width because I wanted to reduce the size.
But this project can be expaneded to expose image-rs (what a beautiful project ๐) with a web interface.
This can be done by exposing the image processing functions as GET parameters. I can think if this being the supported API:
Function
Get Parameters
Type
Default
Status
blur
blur
float (sigma)
0.0
Not Implemented
brighten
brighten
int
0
Not Implemented
huerotate
huerotate
int
0
Not Implemented
contrast
contrast
float
0.0
Not Implemented
crop
(crop_x, crop_y, crop_width, crop_height)
(int, int, int, int)
(0, 0, original_width, original_height)
Not Implemented, if any parameter is supplied, use defaults for others, else don't crop
filter3x3
?
?
Not Implemented, I have no idea what this is
flip_horizontal
fliph
boolean
false
Not Implemented
flip_vertical
flipv
boolean
false
Not Implemented
grayscale
grayscale
boolean
false
Currently: hardcoded to always grayscale
invert
invert
boolean
false
Not Implemented
resize
(width, height, filter?)
(int, int, ?)
(?, ?, ?)
Currently: Harcoded to cap the width at 600. Need to figure out the potential API values for filters.
rotate90
rotate90
boolean
false
Not Implemented
rotate180
rotate180
boolean
false
Not Implemented
rotate270
rotate270
boolean
false
Not Implemented
unsharpen
(unsharpen_sigma, unsharpen_threshold)
(float, int)
(0.0, 0)
Not Implemented
Legend:
? indicates that I don't know anything about that and can't make a decision yet (If you know, please feel free to change it via a PR).
Everything else is where I know something, just enough to make a first wild guess. By no means it means that I know a lot about that image processing function.
(x, y) is a tuple representing multiple get parameters or their types or values