diff options
author | Mark Felder <feld@feld.me> | 2023-11-07 22:03:20 +0000 |
---|---|---|
committer | Mark Felder <feld@feld.me> | 2023-11-13 15:41:39 -0500 |
commit | a4b6e5613fe02fac1a0ec80b8fd6940d2b22f85d (patch) | |
tree | 8bc192bedb5205da214cd076b6e1b0f913f75b51 | |
parent | 577ade75cffaa8bfc1926879435312684354ccda (diff) | |
download | pleroma-a4b6e5613fe02fac1a0ec80b8fd6940d2b22f85d.tar.gz pleroma-a4b6e5613fe02fac1a0ec80b8fd6940d2b22f85d.zip |
Revert "Add Pleroma.Upload.Filter.HeifToJpeg based on vips"
This reverts commit 31d4448ee61b4afac6aa23f8c0287d13aed411a1.
This functionality is not reliably working with vips/vix due to codec patent junk
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | lib/pleroma/upload/filter/heif_to_jpeg.ex | 36 | ||||
-rw-r--r-- | test/fixtures/image.heic | bin | 41465 -> 0 bytes | |||
-rw-r--r-- | test/pleroma/upload/filter/heif_to_jpeg_test.exs | 38 |
4 files changed, 0 insertions, 75 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ced3b678..394eb5179 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -150,7 +150,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Added move account API - Enable remote users to interact with posts - Possibility to discover users like `user@example.org`, while Pleroma is working on `pleroma.example.org`. Additional configuration required. -- Added Pleroma.Upload.Filter.HeifToJpeg to automate converting .heic files from Apple devices to JPEGs which can be viewed in browsers. ### Fixed - Subscription(Bell) Notifications: Don't create from Pipeline Ingested replies diff --git a/lib/pleroma/upload/filter/heif_to_jpeg.ex b/lib/pleroma/upload/filter/heif_to_jpeg.ex deleted file mode 100644 index a2095ba01..000000000 --- a/lib/pleroma/upload/filter/heif_to_jpeg.ex +++ /dev/null @@ -1,36 +0,0 @@ -# Pleroma: A lightweight social networking server -# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/> -# SPDX-License-Identifier: AGPL-3.0-only - -defmodule Pleroma.Upload.Filter.HeifToJpeg do - @behaviour Pleroma.Upload.Filter - alias Pleroma.Upload - alias Vix.Vips.Operation - - @type conversion :: action :: String.t() | {action :: String.t(), opts :: String.t()} - @type conversions :: conversion() | [conversion()] - - @spec filter(Pleroma.Upload.t()) :: {:ok, :atom} | {:error, String.t()} - def filter(%Pleroma.Upload{content_type: "image/avif"} = upload), do: apply_filter(upload) - def filter(%Pleroma.Upload{content_type: "image/heic"} = upload), do: apply_filter(upload) - def filter(%Pleroma.Upload{content_type: "image/heif"} = upload), do: apply_filter(upload) - - def filter(_), do: {:ok, :noop} - - defp apply_filter(%Pleroma.Upload{name: name, path: path, tempfile: tempfile} = upload) do - ext = String.split(path, ".") |> List.last() - - try do - name = name |> String.replace_suffix(ext, "jpg") - path = path |> String.replace_suffix(ext, "jpg") - {:ok, {vixdata, _vixflags}} = Operation.heifload(tempfile) - {:ok, jpegdata} = Operation.jpegsave_buffer(vixdata) - :ok = File.write(tempfile, jpegdata) - - {:ok, :filtered, %Upload{upload | name: name, path: path, content_type: "image/jpeg"}} - rescue - e in ErlangError -> - {:error, "#{__MODULE__}: #{inspect(e)}"} - end - end -end diff --git a/test/fixtures/image.heic b/test/fixtures/image.heic Binary files differdeleted file mode 100644 index efd119a0e..000000000 --- a/test/fixtures/image.heic +++ /dev/null diff --git a/test/pleroma/upload/filter/heif_to_jpeg_test.exs b/test/pleroma/upload/filter/heif_to_jpeg_test.exs deleted file mode 100644 index 7627d18ce..000000000 --- a/test/pleroma/upload/filter/heif_to_jpeg_test.exs +++ /dev/null @@ -1,38 +0,0 @@ -# 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 |