From f77005128a391025c16fb65c47a4272ac003cbf1 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:12:13 +0000 Subject: [performance] move thumbnail generation to go code where possible (#3183) * wrap thumbnailing code to handle generation natively where possible * more code comments! * add even more code comments! * add code comments about blurhash generation * maintain image rotation if contained in exif data * move rotation before resizing * ensure pix_fmt actually selected by ffprobe, check for alpha layer with gifs * use linear instead of nearest-neighbour for resizing * work with image "orientation" instead of "rotation". use default 75% quality for both webp and jpeg generation * add header to new file * use thumb extension when getting thumb mime type * update test models and tests with new media processing * add suggested code comments * add note about thumbnail filter count reducing memory usage --- internal/api/client/instance/instancepatch_test.go | 2 +- internal/api/client/media/mediacreate_test.go | 4 ++-- internal/api/fileserver/servefile_test.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'internal/api') diff --git a/internal/api/client/instance/instancepatch_test.go b/internal/api/client/instance/instancepatch_test.go index bb391537e..5c5d59ef8 100644 --- a/internal/api/client/instance/instancepatch_test.go +++ b/internal/api/client/instance/instancepatch_test.go @@ -858,7 +858,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch8() { "static_url": "http://localhost:8080/fileserver/01AY6P665V14JJR0AFVRT7311Y/attachment/small/`+instanceAccount.AvatarMediaAttachment.ID+`.webp",`+` "thumbnail_static_type": "image/webp", "thumbnail_description": "A bouncing little green peglin.", - "blurhash": "LE9kG#M}4YtO%dRkWEt5Dmoxx?WC" + "blurhash": "LE9as6M}4YtO%dRlWEt6Dmoxx?WC" }`, string(instanceV2ThumbnailJson)) // double extra special bonus: now update the image description without changing the image diff --git a/internal/api/client/media/mediacreate_test.go b/internal/api/client/media/mediacreate_test.go index 4c2725681..7f8cc2d87 100644 --- a/internal/api/client/media/mediacreate_test.go +++ b/internal/api/client/media/mediacreate_test.go @@ -206,7 +206,7 @@ func (suite *MediaCreateTestSuite) TestMediaCreateSuccessful() { Y: 0.5, }, }, *attachmentReply.Meta) - suite.Equal("LcBzLU#6RkRn~qvzRjWF?urqV@jc", *attachmentReply.Blurhash) + suite.Equal("LjCGfG#6RkRn_NvzRjWF?urqV@a$", *attachmentReply.Blurhash) suite.NotEmpty(attachmentReply.ID) suite.NotEmpty(attachmentReply.URL) suite.NotEmpty(attachmentReply.PreviewURL) @@ -291,7 +291,7 @@ func (suite *MediaCreateTestSuite) TestMediaCreateSuccessfulV2() { Y: 0.5, }, }, *attachmentReply.Meta) - suite.Equal("LcBzLU#6RkRn~qvzRjWF?urqV@jc", *attachmentReply.Blurhash) + suite.Equal("LjCGfG#6RkRn_NvzRjWF?urqV@a$", *attachmentReply.Blurhash) suite.NotEmpty(attachmentReply.ID) suite.Nil(attachmentReply.URL) suite.NotEmpty(attachmentReply.PreviewURL) diff --git a/internal/api/fileserver/servefile_test.go b/internal/api/fileserver/servefile_test.go index 9cd1517e2..33afe34d0 100644 --- a/internal/api/fileserver/servefile_test.go +++ b/internal/api/fileserver/servefile_test.go @@ -166,7 +166,7 @@ func (suite *ServeFileTestSuite) TestServeSmallRemoteFileOK() { ) suite.Equal(http.StatusOK, code) - suite.Equal("image/webp", headers.Get("content-type")) + suite.Equal("image/jpeg", headers.Get("content-type")) suite.Equal(fileInStorage, body) } @@ -212,7 +212,7 @@ func (suite *ServeFileTestSuite) TestServeSmallRemoteFileRecache() { ) suite.Equal(http.StatusOK, code) - suite.Equal("image/webp", headers.Get("content-type")) + suite.Equal("image/jpeg", headers.Get("content-type")) suite.Equal(fileInStorage, body) } -- cgit v1.2.3