Resize Image

Is there a way to resize the image before sending it uploadthing? Since I do not need big images, it feels wasteful to save high res images.
6 Replies
Astra
Astra9mo ago
https://docs.uploadthing.com/getting-started/solid#use-the-hook You can use the useUploadThing hook and write a compression algorithm before uploading the file
SolidStart Setup – uploadthing
Docs for the best file uploader to date
Tomnar
TomnarOP9mo ago
Awesome, thanks @Astra However, this looks very different from the next.js code. It uses a component instead of an input field, and I do not see where to put the code there. Here is the example code: https://docs.uploadthing.com/getting-started/appdir#mount-a-button-and-upload
Next.js App Router Setup – uploadthing
Docs for the best file uploader to date
Astra
Astra9mo ago
https://docs.uploadthing.com/api-reference/react#uploadbutton @Tomnar i think using the onBeforeUploadBegin should do it
React – uploadthing
Docs for the best file uploader to date
Tomnar
TomnarOP9mo ago
Can you provide an example? It looks like it has to by sync but all resizing libs I find work asynchronously :/
JulieCezar
JulieCezar9mo ago
It can be async
No description
Tomnar
TomnarOP9mo ago
I thought I had tried that. Thanks you so much @JulieCezar, I will try this first thing tomorrow! It worked, awesome! Turns out I had a type mismatch before ;/
Want results from more Discord servers?
Add your server