I'm using this function another file to take 'file' and integrate it with backend. The console statements are showing that size is getting reduced. But the actual image which is getting transferred to backend is expanding in size.
Please suggest changes using which it runs properly.
Thanks in Advance.
export const imageCompresser = (file) => { console.log(
originalFile size ${file.size / 1024 / 1024} MB); if (file?.length > 0) { const imageFile = file[0]; const options = { maxSizeMB: 1, maxWidthorHeight: 300, maxIteration: 30, useWebWorker: true, }; imageCompression(imageFile, options) .then((compressedFile) => { console.log(
compressedFile size ${compressedFile.size / 1024 / 1024} MB); return compressedFile; }); } if (file) { const imageFile = file; const options = { maxSizeMB: 1, maxWidthorHeight: 300, maxIteration: 30, useWebWorker: true, }; imageCompression(imageFile, options) .then((compressedFile) => { console.log(
compressedFile size ${compressedFile.size / 1024 / 1024} MB); return compressedFile; }); } return file; };
I'm using this function another file to take 'file' and integrate it with backend. The console statements are showing that size is getting reduced. But the actual image which is getting transferred to backend is expanding in size.
Please suggest changes using which it runs properly. Thanks in Advance.