downsizeImage
Public function
Resize an image Blob to be smaller than it is currently.
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.92,
})
Signature
function downsizeImage(
blob: Blob,
width: number,
height: number,
opts?: {
quality?: number | undefined
type?: string | undefined
}
): Promise<Blob>
Parameters
Name | Description |
---|---|
|
|
|
The desired width. |
|
The desired height. |
|
Options for the image. |
Returns
Promise<Blob>
Source