diff --git a/index/images.mk b/index/images.mk index 2ed13496..a96f446a 100644 --- a/index/images.mk +++ b/index/images.mk @@ -42,6 +42,7 @@ metadata: image_search_json 'processed', processed, 'score', score, 'size', image_size, + 'orig_size', image_orig_size, 'sha512_hash', image_sha512_hash, 'thumbnails_generated', thumbnails_generated, 'updated_at', updated_at, diff --git a/lib/philomena/images/image.ex b/lib/philomena/images/image.ex index 3e9c889a..ee03b651 100644 --- a/lib/philomena/images/image.ex +++ b/lib/philomena/images/image.ex @@ -51,6 +51,7 @@ defmodule Philomena.Images.Image do field :image_width, :integer field :image_height, :integer field :image_size, :integer + field :image_orig_size, :integer field :image_format, :string field :image_mime_type, :string field :image_aspect_ratio, :float @@ -137,6 +138,7 @@ defmodule Philomena.Images.Image do :image_width, :image_height, :image_size, + :image_orig_size, :image_format, :image_mime_type, :image_aspect_ratio, @@ -152,6 +154,7 @@ defmodule Philomena.Images.Image do :image_width, :image_height, :image_size, + :image_orig_size, :image_format, :image_mime_type, :image_aspect_ratio, diff --git a/lib/philomena/images/query.ex b/lib/philomena/images/query.ex index 74d1b835..d63fa789 100644 --- a/lib/philomena/images/query.ex +++ b/lib/philomena/images/query.ex @@ -84,7 +84,7 @@ defmodule Philomena.Images.Query do defp anonymous_fields do [ int_fields: - ~W(id width height score upvotes downvotes faves uploader_id faved_by_id pixels size comment_count source_count tag_count) ++ + ~W(id width height score upvotes downvotes faves uploader_id faved_by_id pixels size orig_size comment_count source_count tag_count) ++ tag_count_fields(), float_fields: ~W(aspect_ratio wilson_score duration), date_fields: ~W(created_at updated_at first_seen_at), diff --git a/lib/philomena/images/search_index.ex b/lib/philomena/images/search_index.ex index 2d9265b5..35241ccd 100644 --- a/lib/philomena/images/search_index.ex +++ b/lib/philomena/images/search_index.ex @@ -54,6 +54,7 @@ defmodule Philomena.Images.SearchIndex do processed: %{type: "boolean"}, score: %{type: "integer"}, size: %{type: "integer"}, + orig_size: %{type: "integer"}, sha512_hash: %{type: "keyword"}, source_url: %{type: "keyword"}, source_count: %{type: "integer"}, @@ -117,6 +118,7 @@ defmodule Philomena.Images.SearchIndex do height: image.image_height, pixels: image.image_width * image.image_height, size: image.image_size, + orig_size: image.image_orig_size, animated: image.image_is_animated, duration: if(image.image_is_animated, do: image.image_duration, else: 0), tag_count: length(image.tags), diff --git a/lib/philomena_media/uploader.ex b/lib/philomena_media/uploader.ex index 3df61945..f15e1b9c 100644 --- a/lib/philomena_media/uploader.ex +++ b/lib/philomena_media/uploader.ex @@ -130,6 +130,7 @@ defmodule PhilomenaMedia.Uploader do * `width` (integer) - the width of the file * `height` (integer) - the height of the file * `size` (integer) - the size of the file, in bytes + * `orig_size` (integer) - the size of the file, in bytes * `format` (String) - the file extension, one of `~w(gif jpg png svg webm)`, determined by reading the file * `mime_type` (String) - the file's sniffed MIME type, determined by reading the file * `duration` (float) - the duration of the media file @@ -148,6 +149,7 @@ defmodule PhilomenaMedia.Uploader do :foo_width, :foo_height, :foo_size, + :foo_orig_size, :foo_format, :foo_mime_type, :foo_duration, @@ -221,6 +223,7 @@ defmodule PhilomenaMedia.Uploader do "width" => analysis.width, "height" => analysis.height, "size" => analysis.size, + "orig_size" => analysis.size, "format" => analysis.extension, "mime_type" => analysis.mime_type, "duration" => analysis.duration, diff --git a/lib/philomena_web/views/api/json/image_view.ex b/lib/philomena_web/views/api/json/image_view.ex index d6c8b951..f72a676e 100644 --- a/lib/philomena_web/views/api/json/image_view.ex +++ b/lib/philomena_web/views/api/json/image_view.ex @@ -60,6 +60,7 @@ defmodule PhilomenaWeb.Api.Json.ImageView do height: image.image_height, mime_type: image.image_mime_type, size: image.image_size, + orig_size: image.image_orig_size, duration: image.image_duration, animated: image.image_is_animated, format: image.image_format, diff --git a/priv/repo/migrations/20240723122759_add_images_orig_size.exs b/priv/repo/migrations/20240723122759_add_images_orig_size.exs new file mode 100644 index 00000000..e41ff7af --- /dev/null +++ b/priv/repo/migrations/20240723122759_add_images_orig_size.exs @@ -0,0 +1,9 @@ +defmodule Philomena.Repo.Migrations.AddImagesOrigSize do + use Ecto.Migration + + def change do + alter table("images") do + add :image_orig_size, :integer + end + end +end diff --git a/priv/repo/structure.sql b/priv/repo/structure.sql index ab137a7c..47cf9f04 100644 --- a/priv/repo/structure.sql +++ b/priv/repo/structure.sql @@ -2,8 +2,8 @@ -- PostgreSQL database dump -- --- Dumped from database version 14.1 --- Dumped by pg_dump version 14.1 +-- Dumped from database version 16.3 +-- Dumped by pg_dump version 16.3 SET statement_timeout = 0; SET lock_timeout = 0; @@ -953,7 +953,8 @@ CREATE TABLE public.images ( image_duration double precision, description character varying DEFAULT ''::character varying NOT NULL, scratchpad character varying, - approved boolean DEFAULT false + approved boolean DEFAULT false, + image_orig_size integer ); @@ -4996,6 +4997,9 @@ ALTER TABLE ONLY public.image_tag_locks ALTER TABLE ONLY public.moderation_logs ADD CONSTRAINT moderation_logs_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; + + +-- -- Name: source_changes source_changes_image_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -5051,3 +5055,4 @@ INSERT INTO public."schema_migrations" (version) VALUES (20211009011024); INSERT INTO public."schema_migrations" (version) VALUES (20211107130226); INSERT INTO public."schema_migrations" (version) VALUES (20211219194836); INSERT INTO public."schema_migrations" (version) VALUES (20220321173359); +INSERT INTO public."schema_migrations" (version) VALUES (20240723122759);