Layers Archive
At the moment, the archive is named the same as the original image, so the file extension should be ignored. Example request:
const response = await axios.get(
`https://retoucher.hz.labs.retouch4.me/api/v1/retoucher/getFile/${id}`, {
responseType: "blob"
});
const blob = response.data;
If blob.type === ‘binary/octet-stream’, then it's an archive with layers (PNG images).
Example of extracting layers from the archive:
const fileRequest = await fetch(zipFileUrl);
const result = await fileRequest.blob();
const zip = new JsZip();
await zip.loadAsync(result, { base64: false });
zip.forEach((
path
: string,
jsZipObject
: JsZip.JSZipObject) => {
if (!jsZipObject.dir) {
const
data
= await this.jsZipObject.async("blob");
}
})
In the example above, path is the file name, and data is a Blob containing the data.
Each file's name appears as a query format, for example:
index=0&blendmode=softLight&name=Portrait Volumes.png
index
- the layer's order number.
blendmode
- the blend mode used to merge this layer with the result of previous layers. Can take values likesoftLight, darken, normal
.
name
- the name of the layer, corresponding to the plugin name used for processing (see the Tasks section).