 defmodule DrinkMe.ImageController do
   use DrinkMe.Web, :controller
-
   require HTTPotion
 
   plug :scrub_params, "image" when action in [:create]

    end
  end

  defp modify(path) do
    path |> Mogrify.open |> Mogrify.resize("500x500")
  end

  defp download(path) do

  def create(conn, %{"image" => image_params}) do
    case download(image_params["path"]) do
      { :ok, path } ->
        Task.start fn -> 
          modify(path, image_params["changes"]) 
        end
        render(conn, "show.json", path: path)
      _ ->
        conn
