0

I am able to resize the avatar in the view using

<%= image_tag @user.avatar.variant(resize: "100x100")

But I am wondering if there is a way to resize it before actually uploading the avatar.

When I run the same line in my controller, I get this error:

undefined method `variant' for # <ActionDispatch::Http::UploadedFile:0x00007fcecfdac190>
A.J
  • 1,140
  • 5
  • 23
  • 58

1 Answers1

-1

In order to resize before uploading you can use HTML5 canvas element + Javascript to do the desired processing and then send the image to the server.

Check this question for more details.

Viktor Nonov
  • 1,472
  • 1
  • 12
  • 26