From 42b0e1e8884f5cced939032551dc3197158e619e Mon Sep 17 00:00:00 2001 From: soulofmischief <30357883+soulofmischief@users.noreply.github.com> Date: Tue, 20 Dec 2022 13:24:13 -0800 Subject: [PATCH 1/4] Use jpeg instead of png for prompt image --- src/generators/scene-generator.js | 6 +++--- src/utils/convert-utils.js | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/generators/scene-generator.js b/src/generators/scene-generator.js index e9f32a47..e9d2713e 100644 --- a/src/generators/scene-generator.js +++ b/src/generators/scene-generator.js @@ -3794,7 +3794,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; @@ -4063,7 +4063,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'); @@ -4317,4 +4317,4 @@ export async function compileVirtualScene(imageArrayBuffer) { candidateLocations, predictedHeight, }; -} \ No newline at end of file +} diff --git a/src/utils/convert-utils.js b/src/utils/convert-utils.js index d5c1987f..fd5542ba 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,7 +50,9 @@ 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 => { From 79987d1887ea258c73819222f4d12a230a56ad2c Mon Sep 17 00:00:00 2001 From: soulofmischief <30357883+soulofmischief@users.noreply.github.com> Date: Tue, 20 Dec 2022 13:24:28 -0800 Subject: [PATCH 2/4] Clean up file --- src/utils/convert-utils.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/utils/convert-utils.js b/src/utils/convert-utils.js index fd5542ba..07932ce9 100644 --- a/src/utils/convert-utils.js +++ b/src/utils/convert-utils.js @@ -55,12 +55,11 @@ export async function image2DataUrl(img, className = '') { ); // 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) { @@ -89,4 +88,4 @@ export const resizeImage = (image, width, height) => { ctx.drawImage(image, 0, 0, width, height); } return canvas; -}; \ No newline at end of file +}; From e0bdfe212eeb20bae064b4ac627d316d4cb8be6a Mon Sep 17 00:00:00 2001 From: soulofmischief <30357883+soulofmischief@users.noreply.github.com> Date: Tue, 20 Dec 2022 13:24:13 -0800 Subject: [PATCH 3/4] Use jpeg instead of png for prompt image --- src/generators/scene-generator.js | 6 +++--- src/utils/convert-utils.js | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) 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..fd5542ba 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,7 +50,9 @@ 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 => { From 83a54eda544cd88e9936d6da024dbd02ced5b7af Mon Sep 17 00:00:00 2001 From: soulofmischief <30357883+soulofmischief@users.noreply.github.com> Date: Tue, 20 Dec 2022 13:24:28 -0800 Subject: [PATCH 4/4] Clean up file --- src/utils/convert-utils.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/utils/convert-utils.js b/src/utils/convert-utils.js index fd5542ba..07932ce9 100644 --- a/src/utils/convert-utils.js +++ b/src/utils/convert-utils.js @@ -55,12 +55,11 @@ export async function image2DataUrl(img, className = '') { ); // 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) { @@ -89,4 +88,4 @@ export const resizeImage = (image, width, height) => { ctx.drawImage(image, 0, 0, width, height); } return canvas; -}; \ No newline at end of file +};