Fix crash when unable to resize image

This commit is contained in:
Mitchell McCaffrey 2021-02-14 08:35:43 +11:00
parent 8440a8de42
commit 2f4e671390
2 changed files with 11 additions and 9 deletions

View File

@ -39,7 +39,7 @@ export function getImageLightness(image) {
/** /**
* @typedef ResizedImage * @typedef ResizedImage
* @property {Blob} blob * @property {Blob|null} blob The blob of the resized image, `null` if the image was unable to be resized to that dimension
* @property {number} width * @property {number} width
* @property {number} height * @property {number} height
*/ */

View File

@ -190,14 +190,16 @@ function SelectMapModal({
file.type, file.type,
resolution.quality resolution.quality
); );
const resizedBuffer = await blobToBuffer(resized.blob); if (resized.blob) {
resolutions[resolution.id] = { const resizedBuffer = await blobToBuffer(resized.blob);
file: resizedBuffer, resolutions[resolution.id] = {
width: resized.width, file: resizedBuffer,
height: resized.height, width: resized.width,
type: "file", height: resized.height,
id: resolution.id, type: "file",
}; id: resolution.id,
};
}
} }
} }
// Create thumbnail // Create thumbnail