I had to pass the new file to the is_landscape? and is_portrait? methods to get it to work:
def is_landscape?(new_file)
image = ::MiniMagick::Image::read(File.binread(@file.file))
Rails.logger.info "from in is_landscape? : #{image[:width] > image[:height]}"
image[:width] >= image[:height]
end
def is_portrait?(new_file)
Rails.logger.info "from in is_portrait? : #{ !is_landscape?(new_file)}"
!is_landscape?(new_file)
end
process :resize_to_fill => [667, 500], if: :is_landscape?
process :resize_to_fill => [500, 667], if: :is_portrait?
version :preview do
process :resize_to_fill => [380,285]
end
version :thumb do
process :resize_to_fill => [105,79], if: :is_landscape?
process :resize_to_fill => [105, 158], if: :is_portrait?
end