Spaces:
Running
on
A100
Running
on
A100
Update share_btn.py
Browse files- share_btn.py +6 -3
share_btn.py
CHANGED
|
@@ -24,15 +24,18 @@ share_js = """async () => {
|
|
| 24 |
}
|
| 25 |
|
| 26 |
async function getInputImgFile(imgEl){
|
|
|
|
| 27 |
const res = await fetch(imgEl.src);
|
|
|
|
| 28 |
const blob = await res.blob();
|
|
|
|
| 29 |
const imgId = Date.now() % 200;
|
| 30 |
-
const isPng =
|
| 31 |
if(isPng){
|
| 32 |
-
const fileName = `sd-perception-${
|
| 33 |
return new File([blob], fileName, { type: 'image/png' });
|
| 34 |
}else{
|
| 35 |
-
const fileName = `sd-perception-${
|
| 36 |
return new File([blob], fileName, { type: 'image/jpeg' });
|
| 37 |
}
|
| 38 |
}
|
|
|
|
| 24 |
}
|
| 25 |
|
| 26 |
async function getInputImgFile(imgEl){
|
| 27 |
+
console.log(imgEl)
|
| 28 |
const res = await fetch(imgEl.src);
|
| 29 |
+
console.log(res)
|
| 30 |
const blob = await res.blob();
|
| 31 |
+
console.log(blob.type)
|
| 32 |
const imgId = Date.now() % 200;
|
| 33 |
+
const isPng = blob.type == 'image/png';
|
| 34 |
if(isPng){
|
| 35 |
+
const fileName = `sd-perception-${imgId}.png`;
|
| 36 |
return new File([blob], fileName, { type: 'image/png' });
|
| 37 |
}else{
|
| 38 |
+
const fileName = `sd-perception-${imgId}.jpg`;
|
| 39 |
return new File([blob], fileName, { type: 'image/jpeg' });
|
| 40 |
}
|
| 41 |
}
|