summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2022-11-10 11:07:49 -0500
committerMark Felder <feld@feld.me>2023-11-13 15:41:39 -0500
commit481b6ac0d5c610e840fc4b88a357efa28f510ab8 (patch)
tree507edd3f01412e78380b0609b9e15963e679641d /test
parent13baba90f6deb27b0d6301a705db753cc32bb141 (diff)
downloadpleroma-481b6ac0d5c610e840fc4b88a357efa28f510ab8.tar.gz
pleroma-481b6ac0d5c610e840fc4b88a357efa28f510ab8.zip
Add Pleroma.Upload.Filter.HeifToJpeg based on vips
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/image.heicbin0 -> 41465 bytes
-rw-r--r--test/pleroma/upload/filter/heif_to_jpeg_test.exs38
2 files changed, 38 insertions, 0 deletions
diff --git a/test/fixtures/image.heic b/test/fixtures/image.heic
new file mode 100644
index 000000000..efd119a0e
--- /dev/null
+++ b/test/fixtures/image.heic
Binary files differ
diff --git a/test/pleroma/upload/filter/heif_to_jpeg_test.exs b/test/pleroma/upload/filter/heif_to_jpeg_test.exs
new file mode 100644
index 000000000..7627d18ce
--- /dev/null
+++ b/test/pleroma/upload/filter/heif_to_jpeg_test.exs
@@ -0,0 +1,38 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Upload.Filter.HeifToJpegTest do
+ use Pleroma.DataCase, async: true
+ alias Pleroma.Upload.Filter
+
+ test "apply HeicToJpeg filter" do
+ File.cp!(
+ "test/fixtures/image.heic",
+ "test/fixtures/heictmp"
+ )
+
+ upload = %Pleroma.Upload{
+ name: "image.heic",
+ content_type: "image/heic",
+ path: Path.absname("test/fixtures/image.heic"),
+ tempfile: Path.absname("test/fixtures/heictmp")
+ }
+
+ {:ok, :filtered, result} = Filter.HeifToJpeg.filter(upload)
+
+ assert result.content_type == "image/jpeg"
+ assert result.name == "image.jpg"
+ assert String.ends_with?(result.path, "jpg")
+
+ assert {:ok,
+ %Majic.Result{
+ content:
+ "JPEG image data, JFIF standard 1.02, resolution (DPI), density 96x96, segment length 16, progressive, precision 8, 1024x768, components 3",
+ encoding: "binary",
+ mime_type: "image/jpeg"
+ }} == Majic.perform(result.path, pool: Pleroma.MajicPool)
+
+ on_exit(fn -> File.rm!("test/fixtures/heictmp") end)
+ end
+end