I have a backend that receives a JPEG image as a File object (image/jpeg).
I need to convert the JPEG image to WebP.
The resulting WebP must be a File object (image/webp).
For example:
File object (image/jpeg) => to stream => to webp => to File object (image/webp)
I got as far as converting the stream to webp, but I can't find any info on how to convert it back to File (or at least a modified Blob with the same exact properties/methods of File).
Just to be clear, this is what I mean by File
object:
File {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
size: 38718,
path: '/var/folders/17/lk7n1gkd6m54kzmr0g7kqdn80000gp/T/upload_62e5a3f95bccb09b605722a21737cbc3',
name: '09_scan_qr.jpg',
type: 'image/jpeg',
hash: null,
lastModifiedDate: 2023-01-05T03:37:24.134Z,
_writeStream: WriteStream {
fd: null,
path: '/var/folders/17/lk7n1gkd6m54kzmr0g7kqdn80000gp/T/upload_62e5a3f95bccb09b605722a21737cbc3',
flags: 'w',
mode: 438,
start: undefined,
pos: undefined,
bytesWritten: 38718,
closed: false,
_writableState: WritableState {...},
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
[Symbol(kFs)]: {...}
}