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'

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

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


On Sunday, April 28, 2019 at 2:29:02 PM UTC+5:30, Ryan Richardson wrote:

> 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? 
>
> On Thursday, November 22, 2018 at 8:53:47 AM UTC-8, DHH wrote:
>>
>> 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.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to