immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
49.63k stars 2.62k forks source link

[Feature]: Add option to optimize uploaded images automatically #1202

Closed DVerdeV closed 1 year ago

DVerdeV commented 1 year ago

Feature detail

The vast majority of home users don't notice if any compression is applied to the image.

I have tested this with the ImageMagick tool on Linux and by changing the quality. Personally, I've started to notice it when I lower it to 35%. I think it is a good idea to add an option to compress images when uploading, as this would allow storing many, many more in the same space using a negligible amount of server usage.

According to tests I have done, a 5.8 MB image can be reduced to 350 KB (35% quality).

Platform

Server

alextran1502 commented 1 year ago

Then if you want to retrieve the original file to print, you cannot do it anymore

DVerdeV commented 1 year ago

Then if you want to retrieve the original file to print, you cannot do it anymore

A small section could be added in the settings to adjust this compression and enable/disable it. Obviously, there are people who then print some stored photos, but for a user who takes a lot of photos, it might be better to be able to store a lot of them using less storage space.

Google Photos did this with their “high quality/storage saver” backup option. Find here what they have on their help page about that: image

I think those are good dimensions for a print of a photograph and enough for albums, gifts, etc…

alextran1502 commented 1 year ago

Closing this issue as it is not in scope of the project

lpryszcz commented 1 year ago

Hi, I find this feature useful as well. But this can be done manually directly on the library. Does immich store file size/md5 in the database? If image is compressed, this would change its size and hash, possibly breaking things. Thank you!

btw, immich is amazing!

alextran1502 commented 1 year ago

@lpryszcz Immich stores file size and md5 in the database and use md5 to check for duplication.

WinnerOK commented 1 year ago

@lpryszcz would you be interested to collaborate and find a way to compressed already stored images at least manually server-side ?

I see the following possible options:

  1. (extremely hacky) - run a script that will compress existing images in-place and recalculate hash
  2. (better but more difficult) - implement an endpoint in server to compress input images or manually compress old images. Although this feature is somewhat requested in https://github.com/immich-app/immich/issues/165#issuecomment-1138042361 it might fall the same failth as the original issue: https://github.com/immich-app/immich/issues/165#issuecomment-1575164317

I suggest for us to try hacky ways to optimize a file storage and only after to try and create more or less stable PR to immich

Useful links: DB queries

lpryszcz commented 1 year ago

I like the idea @WinnerOK .

I see the following possible options:

  1. (extremely hacky) - run a script that will compress existing images in-place and recalculate hash

This is also my favourite (at least for now). The problem I see it that if we compress and update the db, it'll cause mobile client to upload the same photos again if they are not removed already.

  1. We could play directly with the client (app) so it uploads compressed/reduced images (similar to "the other" app).

The main question is, how stable is DB design? It makes little sense to develop something that will be broken with future releases (this is why #165 is on hold as far as I understand, right?).

WinnerOK commented 1 year ago

We could play directly with the client (app) so it uploads compressed/reduced images (similar to "the other" app).

If we do client-side compression and use hash of compressed file for dedup, then client will have to repeat compression to properly check for duplicates. This seems like a lot of work for client.

The original image in high-quality should still be available on user's device. Therefore, we should check for duplicates based on the original hash. (Keep in mind that current hashing is server sided, but it could become client sided at one time: https://github.com/immich-app/immich/issues/2567)

If we have to consider original file hash, then we have to make sure that hash in the DB is only used for deduplication and does not actually get verified afterwards (otherwise we have to store 2 hashes in the DB) then we could just store the original hash. @alextran1502 could you tell us if immich uses file hash anywhere except deduplication during upload?


If we would dive into server, we could also somewhat address the issue mentioned above (https://github.com/immich-app/immich/issues/1202#issuecomment-1366894485 ) by adding 2 configurations:

  1. Upload quality: compressed or original. This speaks for itself.
  2. If upload quality is original we can show a slider compress photos older than X days/years/never and also add a checkmark never compress favourite media

This way people who have limited storage can give up on quality, but still preserve their favourite moments as is

aviv926 commented 1 year ago

I see someone started something about it here #1242

also someone made something that already work with immich

https://gist.github.com/JamesCullum/6604e504318dd326a507108f59ca7dcd

athornfam2 commented 11 months ago

I'm interested in an on/off switch as well. My family and I don't particularly see the point in anything larger than 8MP or 12MP anyways. I

aviv926 commented 11 months ago

I'm interested in an on/off switch as well. My family and I don't particularly see the point in anything larger than 8MP or 12MP anyways. I

Unfortunately according to the developer of the project this is not a feature that will be added in the near future or at all

In my reply above, I showed how it is possible to still apply compression to details, but it seems that this is something that affects the entire library and cannot be selected per user

athornfam2 commented 11 months ago

I'm interested in an on/off switch as well. My family and I don't particularly see the point in anything larger than 8MP or 12MP anyways. I

Unfortunately according to the developer of the project this is not a feature that will be added in the near future or at all

In my reply above, I showed how it is possible to still apply compression to details, but it seems that this is something that affects the entire library and cannot be selected per user

it's unfortunate as it could save a tremendous amount of space for those of us that don't need original quality on a remote server especially if the photo is cached locally. I guess I'll have to look into a solution for that. Do you know of any that have been created by other users?

AngelaDMerkel commented 1 month ago

My issue #8907 was recently closed as a duplicate of this unfortunately (also) closed issue. I think this makes it pretty clear that the team won't work on this issue. It would be a great solution to be able to toggle with users even if only for video. Images occupy a miniscule amount of space relatively speaking, but a lot of my users are uploading giant 4K videos don't really benefit from their inflated bitrates and my machine is already doing the work to convert to proxies for viewing. I understand it's a against the spirit of Immich as the developers see it, but it would go a very long way to making this a much more versatile solution