Best way to resize images already uploaded with allow_upload?

I have an app that is currently in production. I have images being uploaded directly to the apps upload folder because in total there will only need to be less than 100 images and I anticipated them to be uploaded as much smaller files than they were. As soon as I went online and before I could convert the images 40 images were uploaded all around 15mb and it really slows the page down. What is the best way to convert all the images from jpg to webp and change the size? Do I need to delete them all and reupload?

If you want to write a script to run on the server, look no further than Image! It has native bindings to VIPS (through the Vix lib) so all you need to do is add it to your deps and you’re good!

Thank you! Just what I was looking for.

Another option for this particular type of problem is to let people upload files in whatever format and size they want, and then use an image resizing proxy (such as imgproxy, or one built into your app using the Image library) to resize them at runtime, and then place that proxy behind a CDN.

That way, you can change the image size in HTML and when you deploy, all of the images will magically be the new size. It also allows you to have different sized images for phone vs desktop layouts, and lets you easily supply multiple resolutions of an image and let the browser decide which is the appropriate one to pick via the srcset attribute.