require "tempfile" class Gif def self.convert_jpg_to_gif(arr) if arr.length == 1 a = "#{Rails.root}/public/gif/1.jpeg" b = "#{Rails.root}/public/gif/2.jpeg" c = arr[0] d = "#{Rails.root}/public/gif/4.jpeg" elsif arr.length == 2 a = arr[0] b = "#{Rails.root}/public/gif/2.jpeg" c = arr[1] d = "#{Rails.root}/public/gif/4.jpeg" elsif arr.length == 3 a = arr[0] b = arr[1] c = arr[-1] d = "#{Rails.root}/public/gif/4.jpeg" elsif arr.length == 4 a = arr[0] b = arr[1] c = arr[-1] d = arr[2] end system("convert #{b} -background 'rgba(0,0,0,0.0)' -rotate \"-20\" #{Rails.root}/public/gif/22.gif") system("convert #{d} -background 'rgba(0,0,0,0.0)' -rotate \"-20\" #{Rails.root}/public/gif/41.gif") system("composite -gravity NorthEast -geometry 18x18+102+32 #{a} #{Rails.root}/public/gif/1231.gif #{Rails.root}/public/gif/a.gif ") system("composite -gravity SouthWest -geometry 22x22+15+48 #{Rails.root}/public/gif/22.gif #{Rails.root}/public/gif/a.gif #{Rails.root}/public/gif/a.gif") system("composite -gravity SouthEast -geometry 26x26+86+26 #{c} #{Rails.root}/public/gif/a.gif #{Rails.root}/public/gif/a.gif ") #71X26 system("composite -gravity SouthEast -geometry 16x16+24+81 #{Rails.root}/public/gif/41.gif #{Rails.root}/public/gif/a.gif #{Rails.root}/public/gif/b1.gif ") system("convert #{b} -background 'rgba(0,0,0,0.0)' -rotate \"+20\" #{Rails.root}/public/gif/22.gif") system("composite -gravity NorthEast -geometry 18x18+102+32 #{a} #{Rails.root}/public/gif/1232.gif #{Rails.root}/public/gif/a1.gif ") system("composite -gravity SouthWest -geometry 22x22+19+49 #{Rails.root}/public/gif/22.gif #{Rails.root}/public/gif/a1.gif #{Rails.root}/public/gif/a1.gif ") system("composite -gravity SouthWest -geometry 26x26+71+26 #{c} #{Rails.root}/public/gif/a1.gif #{Rails.root}/public/gif/a1.gif ") #71X26 system("composite -gravity SouthEast -geometry 16x16+24+81 #{Rails.root}/public/gif/41.gif #{Rails.root}/public/gif/a1.gif #{Rails.root}/public/gif/b2.gif ") system("convert -delay 100 -dispose Background #{Rails.root}/public/gif/b1.gif #{Rails.root}/public/gif/b2.gif -loop 0 #{Rails.root}/public/gif/b3.gif") "#{Rails.root}/public/gif/b3.gif" end end?