image search by name

This commit is contained in:
2022-12-17 22:15:59 +02:00
parent 1aa092c433
commit 430de769ee
3 changed files with 34 additions and 32 deletions

View File

@ -31,12 +31,15 @@ module Merged
end
def aspect_ratio
ratio = self.width.to_f / self.height
ratio = self.ratio
ratios = (1..9).collect{ |i| ((ratio * i) - (ratio * i).round(0)).abs }
min , min_index = ratios.each_with_index.min
[(ratio * (min_index + 1) ).to_i , (min_index + 1) ]
end
def ratio
self.width.to_f / self.height
end
#save an io with given name (without ending, that is taken from io)
#Should save to tmp first
def self.create_new(filename , io)