[ActiveStorage] Resize original image


Currently with the ActiveStorage:Variant has the image.variant(resize: '100x100').processed method that creates a version of the image without modifying the original image.

It would be very useful if there was a method to modify the original image.

It’s possible and viable?

Thanks all

These uploads are considered immutable. If you want to store something else than the original, you should do the transformation on the original and upload the new image.

I have a small app where I’m allowing uploads of photos from cell phones via ActiveStorage. In order to not require users to change their default cell phone camera settings, I’m currently allowing image uploads of unnecessary file size. Would it be feasible to hook in after the asset data is posted, but before the uploaded asset is initially pushed to cloud storage, in order to reduce the asset’s file size to a more reasonable max?

Hello Ryan,

As far as, I understand after reading your issue that you want to reduce the size of uploaded image before storing it to the cloud storage.

Ryan, as DHH told in the above thread that uploads are considered immutable so Active Storage doesn’t support transforming/resizing the image itself. We’ll need to use the ImageMagick gem to do the resizing.

We keep it simple and use a nice gem which does the work for us.

  1. We have to add the image_processing gem to your Gemfile.

gem ‘image_processing’


  1. After adding gem and bundle install, we can use a variant in view like

<%= image_tag image.variant(resize: “100x100”) %>


Hi Ashish,
Thanks for your response! Being as the original feature request is 5 months old, I figured it was worth revisiting as a possibility. My problem is not in serving resized assets (still a really awesome feature!) but rather the inefficient use of cloud storage. When someone is uploading photo evidence (live pinball scores in my case), we don’t want to tell them they need to change their camera settings when their photos exceed a specified size (it doesn’t appear you can natively do this at all on iOS in fact). Ultimately, we don’t want to run up a big S3 bill storing assets at 10+ times their necessary resolution. If ActiveStorage is not a candidate for such a feature, is there an alternative option that can be recommended to solve this problem?

Thanks again!

  • Ryan

Hey Ryan—

How about resizing after upload and destroying the original?