logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

analyze_metadata_test.exs (1551B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Upload.Filter.AnalyzeMetadataTest do
  5. use Pleroma.DataCase, async: true
  6. alias Pleroma.Upload.Filter.AnalyzeMetadata
  7. test "adds the dimensions and blurhash for images" do
  8. upload = %Pleroma.Upload{
  9. name: "an… image.jpg",
  10. content_type: "image/jpeg",
  11. path: Path.absname("test/fixtures/image.jpg"),
  12. tempfile: Path.absname("test/fixtures/image.jpg")
  13. }
  14. {:ok, :filtered, meta} = AnalyzeMetadata.filter(upload)
  15. assert %{width: 1024, height: 768} = meta
  16. assert meta.blurhash
  17. end
  18. test "it blurhashes images with an alpha component" do
  19. upload = %Pleroma.Upload{
  20. name: "an… image.jpg",
  21. content_type: "image/jpeg",
  22. path: Path.absname("test/fixtures/png_with_transparency.png"),
  23. tempfile: Path.absname("test/fixtures/png_with_transparency.png")
  24. }
  25. {:ok, :filtered, meta} = AnalyzeMetadata.filter(upload)
  26. assert %{width: 320, height: 320} = meta
  27. assert meta.blurhash == "eXJi-E:SwCEm5rCmn$+YWYn+15K#5A$xxCi{SiV]s*W:Efa#s.jE-T"
  28. end
  29. test "adds the dimensions for videos" do
  30. upload = %Pleroma.Upload{
  31. name: "coolvideo.mp4",
  32. content_type: "video/mp4",
  33. path: Path.absname("test/fixtures/video.mp4"),
  34. tempfile: Path.absname("test/fixtures/video.mp4")
  35. }
  36. assert {:ok, :filtered, %{width: 480, height: 480}} = AnalyzeMetadata.filter(upload)
  37. end
  38. end