sharp-server
v1.0.0
Published
Node server to handle image processing using sharp
Downloads
2
Readme
sharp-server
Convert any image with a HTTP POST request
- Send a HTTP POST request
- Let sharp convert/optimize your image
- Do something with the response
Accept
Set the accept
header with the desired output MIME type.
e.g. "accept": "image/webp"
Options
Resize
Set the resize-options
header, with a JSON string of sharp resize options.
Output
Set the output-options
header, with a JSON string of sharp output options
relevant to the output type set in accept
header.
Example usage
Using defaults
fetch("my.domain.io",{
method: "POST",
headers: {
"content-type": "image/jpeg",
"accept": "image/webp"
},
body: arrayBuffer
});
Setting resize & output options
AVIF output
fetch("my.domain.io",{
method: "POST",
headers: {
"content-type": "image/jpeg",
"accept": "image/avif"
"resize-options": { "width": 750, "withoutEnlargement": true }
"output-options": { "speed": 8 }
},
body: arrayBuffer
});
WebP output
fetch("my.domain.io",{
method: "POST",
headers: {
"content-type": "image/jpeg",
"accept": "image/webp"
"resize-options": { "width": 750, "withoutEnlargement": true }
"output-options": { "reductionEffort": 6 }
},
body: arrayBuffer
});