pdufour commited on
Commit
8e6c9d6
1 Parent(s): 2a0be89

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +6 -7
index.js CHANGED
@@ -331,17 +331,16 @@ example.addEventListener('click', (e) => {
331
  parse(EXAMPLE_URL, 'Describe this image.');
332
  });
333
 
334
- fileUpload.addEventListener('change', function(e) {
335
  const file = e.target.files[0];
336
  if (!file) return;
337
 
338
  const image = await RawImage.fromURL(url);
339
-
340
- // const ar = image.width / image.height;
341
- // const [cw, ch] = (ar > 1) ? [640, 640 / ar] : [640 * ar, 640];
342
- // imageContainer.style.width = `${cw}px`;
343
- // imageContainer.style.height = `${ch}px`;
344
- // imageContainer.style.backgroundImage = `url(${url})`;
345
 
346
  const reader = new FileReader();
347
  // reader.onload = e2 => parse(e2.target.result, '');
 
331
  parse(EXAMPLE_URL, 'Describe this image.');
332
  });
333
 
334
+ fileUpload.addEventListener('change', async function(e) {
335
  const file = e.target.files[0];
336
  if (!file) return;
337
 
338
  const image = await RawImage.fromURL(url);
339
+ const ar = image.width / image.height;
340
+ const [cw, ch] = (ar > 1) ? [640, 640 / ar] : [640 * ar, 640];
341
+ imageContainer.style.width = `${cw}px`;
342
+ imageContainer.style.height = `${ch}px`;
343
+ imageContainer.style.backgroundImage = `url(${url})`;
 
344
 
345
  const reader = new FileReader();
346
  // reader.onload = e2 => parse(e2.target.result, '');