File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed
Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -60,15 +60,19 @@ const compressedImage = await compressFile(file);
6060< html lang= " en" >
6161 < head>
6262 < script src
= " https://cdn.jsdelivr.net/npm/[email protected] /dist/simple-image-compressor.js" >< / script
> 63- < script defer>
64- const fileInput = document .getElementById (' file-input' );
65- const file = fileInput .files [0 ];
66- const options = {
67- quality: 0.9 ,
68- type: ' image/jpeg' ,
69- }
70- const compressedImage = await imageCompressor .compressImage (file, options);
71- // do something with that image...
63+ < script>
64+ window .onload = () => {
65+ const fileInput = document .getElementById (' file-input' );
66+ fileInput .addEventListener (' change' , async () => {
67+ const file = fileInput .files [0 ];
68+ const options = {
69+ quality: 0.9 ,
70+ type: imageCompressor .imageTypes .WEBP ,
71+ };
72+ const compressedImage = await imageCompressor .compressImage (file, options);
73+ // do something with the compressed image
74+ });
75+ };
7276 < / script>
7377 < / head>
7478
You can’t perform that action at this time.
0 commit comments