mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-12 00:37:19 +00:00
Merge pull request #1080 from pekeq/doc-resize-with-aspect
libsquoosh/README: Add code example to resize with aspect ratio preserved.
This commit is contained in:
@@ -42,11 +42,19 @@ When an image has been ingested, you can start preprocessing it and encoding it
|
|||||||
await image.decoded; //Wait until the image is decoded before running preprocessors.
|
await image.decoded; //Wait until the image is decoded before running preprocessors.
|
||||||
|
|
||||||
const preprocessOptions = {
|
const preprocessOptions = {
|
||||||
|
//When both width and height are specified, the image resized to specified size.
|
||||||
resize: {
|
resize: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
width: 100,
|
width: 100,
|
||||||
height: 50,
|
height: 50,
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//When either width or height is specified, the image resized to specified size keeping aspect ratio.
|
||||||
|
resize: {
|
||||||
|
enabled: true,
|
||||||
|
width: 100,
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
await image.preprocess(preprocessOptions);
|
await image.preprocess(preprocessOptions);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user