Resize and optimise images on upload with ActiveStorage

31-Oct-2020 1599
This posts describes how to reduce the size of images uploaded with ActiveStorage significantly by combining a few optimisations.There are user uploads in the app for other things but the above are specifically for images. DynaBlogger is a Rails app, so for this I use ActiveStorage, which is quickly becoming the standard way of handling uploads in Rails since it's built in the framework and doesn't require additional dependencies or even database migrations for models that require attachments, making things simpler than with other solutions provided that you stick to ActiveStorage's conventions.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle