5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ActiveStorageで取得した画像の向きをminimagickのauto_orientに調整してもらう

Last updated at Posted at 2018-07-31

問題点

スマートフォンで撮影した写真をActiveStorageを利用して保存&WEBサイト上に表示すると、90度向きが回転した状態で表示されてしまう。

解決方法

minimagickauto_orientを利用して、画像の向きを自動で調整してもらう。

参考:minimagick/minimagick: mini replacement for RMagick

Gemfile
gem 'mini_magick'
show.html.erb
<%# 修正前 %>
<%= image_tag @user.avatar %>

<%# 修正後 %>
<%= image_tag @user.avatar.variant(auto_orient: true) %>
5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?