Back to Parent

get "/image" do

  #if not media_url.nil? and not media_url == "" and media_content.include? "image"

    image_url = 'https://imagga-com-assets.azureedge.net/static/images/tagging/chris-brignola-7766.jpg'

    url = URI("http://api.imagga.com/v1/colors?url=#{image_url}&version=2")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Get.new(url)
    request["accept"] = 'application/json'
    request["authorization"] = '<authorization code>'

    response = http.request(request)


    data = JSON.parse(response.body)

    $color1 = data["results"][0]["info"]["background_colors"][0]["closest_palette_color_parent"]
    $color2 = data["results"][0]["info"]["background_colors"][1]["closest_palette_color_parent"]


    puts $color1 + "  " + $color2



end
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0