multimodalart HF staff commited on
Commit
e3081ed
1 Parent(s): ee50f53

Update share_btn.py

Browse files
Files changed (1) hide show
  1. 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 = imgEl.src.startsWith(`data:image/png`);
31
  if(isPng){
32
- const fileName = `sd-perception-${{imgId}}.png`;
33
  return new File([blob], fileName, { type: 'image/png' });
34
  }else{
35
- const fileName = `sd-perception-${{imgId}}.jpg`;
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
  }