📣 End of Lifetime Notice: We no longer provide support for this repository. It will be made readonly, you can still fork it and adapt it to your needs.
Compress, Squash and Stampf your Images in a convenient way. Out-of-the-Box Docker Image with Web-GUI to perform lossless PNG and JPG compression.
Microservice of Kartoffelstampf Project that executes the CLI Image Processing and provides a WebSocket API
Serves the Frontend Angular App (only if injected into
public
folder)
Download a compressed file. This is available as soon as it has been compressed via WebSocket call.
🔺 REQUEST-PARAMETERS
:temporaryFileName
The temporary filename generated by the server on upload. E.g.a67876987098768.jpg
:originalFileName
The original filename as the file was named on the computer of the user. E.g.cat.jpg
🔸 REQUEST-BODY
- none
🔹 RESPONSE-BODY
- HTTP 200 - File download
-BINARY OCTET STREAM-
- HTTP 400 - Validation Error. Filenames invalid or other error
{
"error": "Invalid filename"
}
🔶 EXAMPLE
curl http://localhost:9999/download/a67876987098768.jpg/cat.jpg
Will result in a67876987098768.jpg
downloaded as cat.jpg
.
Upload a JPG or PNG as BASE64 encoded Data URI. Server returns the temporary file name.
🔺 REQUEST-PARAMETERS
- none
🔸 REQUEST-BODY
{
"contentDataUri": "data:image/png;base64,iVBORw0KGgoAAAANS..."
}
🔹 RESPONSE-BODY
- HTTP 200 - Upload ok. Filename is returned.
{
"fileName": "a67876987098768.jpg"
}
- HTTP 400 - Validation Error. Unsupported Filetype or file too large.
{
"error": "File size too large"
}
Send a compress image command through Websocket through the WebSocket and and receive STDOUT and STDERR back through the WebSocket. The files must be uploaded first via the
/upload
endpoint. The WebSocket closes once the compression is done. In the Frontend this is wrapped in a RxJS Observable that completes once the WebSocket closes.
LOSSLESS_PNG optipng -o5 /u/a78gz86g7hu.png
const ws = new WebSocket("ws://localhost:9999/");
ws.onopen = function (event) {
ws.send(JSON.stringify({
compressType: 'LOSSLESS',
temporaryFileName: 'a78gz86g7hu.png'
}));
};
ws.onmessage = function(event) {
console.log(event.data);
};
LOSSLESS_JPG jpegoptim -m80 /u/a78gz86g7hu.jpg
const ws = new WebSocket("ws://localhost:9999/");
ws.onopen = function (event) {
ws.send(JSON.stringify({
compressType: 'LOSSLESS',
temporaryFileName: 'a78gz86g7hu.jpg'
}));
};
ws.onmessage = function(event) {
console.log(event.data);
};
The console.log then should show (in a timely manner)
{"payload":{"text":"/u/a78gz86g7hu.jpg "},"type":"stdout"}
{"payload":{"text":"3888x2592 24bit N ICC JFIF "},"type":"stdout"}
{"payload":{"text":" [OK] "},"type":"stdout"}
{"payload":{"text":"2300500 --> 1647661 bytes (28.38%), optimized.\n"},"type":"stdout"}
{"payload":{"exitCode":"0","text":"child process exited with code 0"},"type":"processStatus"}
See DEVELOPMENT.md.