downsizeImage
See source codeResize an image Blob to be smaller than it is currently.
function downsizeImage(
blob: Blob,
width: number,
height: number,
opts?: {
quality?: number | undefined
type?: string | undefined
}
): Promise<Blob>
Example
const image = await(await fetch('/image.jpg')).blob()
const size = await getImageSize(image)
const resizedImage = await downsizeImage(image, size.w / 2, size.h / 2, {
type: 'image/jpeg',
quality: 0.85,
})
Parameters
Name | Description |
---|---|
|
|
|
The desired width. |
|
The desired height. |
|
Options for the image. |
Returns
Promise<Blob>
Prev
createShapesForAssetsNext
exportAs