Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/generators/scene-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -4547,4 +4547,4 @@ export async function compileVirtualScene(imageArrayBuffer) {
edgeDepths,
paths,
};
}
}
11 changes: 6 additions & 5 deletions src/utils/convert-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
}

Expand All @@ -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) {
Expand Down Expand Up @@ -87,4 +88,4 @@ export const resizeImage = (image, width, height) => {
ctx.drawImage(image, 0, 0, width, height);
}
return canvas;
};
};