diff --git a/src/generators/scene-generator.js b/src/generators/scene-generator.js index ce5ae3c2..3042bcbc 100644 --- a/src/generators/scene-generator.js +++ b/src/generators/scene-generator.js @@ -3817,7 +3817,7 @@ export class PanelRenderer extends EventTarget { const editedImgBlob = new Blob([ editedImg, ], { - type: 'image/png', + type: 'image/jpeg', }); editedImgTex.image = await blob2img(editedImgBlob); editedImgTex.needsUpdate = true; @@ -4086,7 +4086,7 @@ const _getImageSegements = async imgBlob => { export async function compileVirtualScene(imageArrayBuffer) { // color const blob = new Blob([imageArrayBuffer], { - type: 'image/png', + type: 'image/jpeg', }); const img = await blob2img(blob); img.classList.add('img'); @@ -4547,4 +4547,4 @@ export async function compileVirtualScene(imageArrayBuffer) { edgeDepths, paths, }; -} \ No newline at end of file +} diff --git a/src/utils/convert-utils.js b/src/utils/convert-utils.js index d5c1987f..07932ce9 100644 --- a/src/utils/convert-utils.js +++ b/src/utils/convert-utils.js @@ -31,7 +31,7 @@ export function img2canvas(img) { export function canvas2blob(canvas) { return new Promise((accept, reject) => { - canvas.toBlob(accept, 'image/png'); + canvas.toBlob(accept, 'image/jpeg'); }); } @@ -50,15 +50,16 @@ export async function image2DataUrl(img, className = '') { document.body.appendChild(canvas); // get the blob - const blob = await new Promise(resolve => canvas.toBlob(resolve, 'image/png')); + const blob = await new Promise(resolve => + canvas.toBlob(resolve, 'image/jpeg') + ); // get the blob url // read the data url from the blob - const dataUrl = await new Promise(resolve => { + return await new Promise(resolve => { const reader = new FileReader(); reader.onload = e => resolve(e.target.result); reader.readAsDataURL(blob); }); - return dataUrl; } export function img2ImageData(img) { @@ -87,4 +88,4 @@ export const resizeImage = (image, width, height) => { ctx.drawImage(image, 0, 0, width, height); } return canvas; -}; \ No newline at end of file +};