Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.3KB

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Upload.Filter.Mogrifun do
  5. @behaviour Pleroma.Upload.Filter
  6. alias Pleroma.Upload.Filter
  7. @filters [
  8. {"implode", "1"},
  9. {"-raise", "20"},
  10. {"+raise", "20"},
  11. [{"-interpolate", "nearest"}, {"-virtual-pixel", "mirror"}, {"-spread", "5"}],
  12. "+polaroid",
  13. {"-statistic", "Mode 10"},
  14. {"-emboss", "0x1.1"},
  15. {"-emboss", "0x2"},
  16. {"-colorspace", "Gray"},
  17. "-negate",
  18. [{"-channel", "green"}, "-negate"],
  19. [{"-channel", "red"}, "-negate"],
  20. [{"-channel", "blue"}, "-negate"],
  21. {"+level-colors", "green,gold"},
  22. {"+level-colors", ",DodgerBlue"},
  23. {"+level-colors", ",Gold"},
  24. {"+level-colors", ",Lime"},
  25. {"+level-colors", ",Red"},
  26. {"+level-colors", ",DarkGreen"},
  27. {"+level-colors", "firebrick,yellow"},
  28. {"+level-colors", "'rgb(102,75,25)',lemonchiffon"},
  29. [{"fill", "red"}, {"tint", "40"}],
  30. [{"fill", "green"}, {"tint", "40"}],
  31. [{"fill", "blue"}, {"tint", "40"}],
  32. [{"fill", "yellow"}, {"tint", "40"}]
  33. ]
  34. def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
  35. Filter.Mogrify.do_filter(file, [Enum.random(@filters)])
  36. :ok
  37. end
  38. def filter(_), do: :ok
  39. end