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
Astra3mo 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
Tomnar3mo 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
Astra3mo 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
Tomnar3mo ago
Can you provide an example? It looks like it has to by sync but all resizing libs I find work asynchronously :/
JulieCezar
JulieCezar3mo ago
It can be async
No description
Tomnar
Tomnar3mo 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
More Posts
white stroke and transparent fillhey guys, wonder if there's anyone good with css here 😅 can anyone tell me why this outline looks l(SEARCHING) Visual API Design SiteHi, I've seen a website that allows you to visualize your website processes (api), but I can't rememManaging High Bandwidth Consumption in Web Hosting and Cloud StorageWhen using a web hosting service like Netlify or Vercel, it's advised to store files in cloud storagplease help me on convincing my manager to choose react native over flutter:)Hi, so the current application is Windows app written with VisualBasic and it is ERP/MRP(material renext js production problem with authI’ve just deployed my app to vercel and when you enter it redirects instantly to auth which does notHow to interact with typescript language server programetically?I am trying to build an app for user searching queries through language server. Maybe later on that Help with dynamic image in Nuxt!does anyone know to import dynamic assets because ```<img :src="`/_nuxt/assets/images/${item.imageHow would you define 'Confidence' in testing? (Unit / Integration / E2E / Whatever)As titled. Most people claim that the purpose of testing is to maintain / improve 'confidence'. But.Has anyone here tried nuqs?Short for next-usequerystate: https://nuqs.47ng.com Seems like a pretty awesome/promising way to inHelp responding to coworkers on my technical decisions (NextJS)I feel like I'm at a point where I'm writing great quality software by blind-following best practice