LoginSignup
0
0

More than 3 years have passed since last update.

【rails】画像の向きを整える方法(ActiveStorage)

Last updated at Posted at 2020-02-25

はじめに

初学者がポートフォリオ作成でハマったことをメモします。
投稿した画像の上下が逆になるバグが発生した。
画像アップロードにはActiveStorageを使用しています。

環境

Ruby 2.6.3 ,Rails 5.2.4

方法

minimagickの設定でauto_orient: trueを記述する。

= image_tag review.avatar.variant(combine_options:{resize:"300x300^",crop:"300x300+0+0",gravity: :center,  auto_orient: true}).processed

これでEXIF情報のOrientation属性(画像の向きを規定している)を変更してくれるみたいです。

最後に

誰かのお役にたてれば幸いです。
間違えている部分があればコメントお願いいたします。

参考にした記事
https://tutorialmore.com/questions-2589404.htm
https://qiita.com/NaokiIshimura/items/a71cc118774e06d418c4
http://dqn.sakusakutto.jp/2009/02/jpegexiforientaion.html

0
0
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
0
0