CatimaLoyalty / Android

Catima, a Loyalty Card & Ticket Manager for Android
https://catima.app
GNU General Public License v3.0
818 stars 150 forks source link

Use jpeg to store images #891

Open matsievskiysv opened 2 years ago

matsievskiysv commented 2 years ago

Using JPEG may significantly reduce images size. For example, one of my cards is 1M in png and 70k in jpg, My exported card archive is 150M in png and 3M in jpeg.

TheLastProject commented 2 years ago

I would assume that switching it to JPEG would break the use case of users who use things like company logos with transparency.

Maybe we can somehow detect if any transparency is used and if not, compress to JPEG? Is JPEG always smaller or just most of the time?

matsievskiysv commented 2 years ago

Is JPEG always smaller or just most of the time?

If it is a photo, it will be smaller in jpeg. But indeed it does not support alpha channel.

Altonss commented 2 years ago

Is JPEG always smaller or just most of the time?

You can choose different compression levels, but yes jpeg may reduce size quite a bit :)

Shanta-11 commented 1 year ago

@TheLastProject We can give the choice of either exporting to png or jpeg.

I can work on it.

TheLastProject commented 1 year ago

We can give the choice of either exporting to png or jpeg.

I understand your suggestion, but I'm not really a fan of it. I don't think the average user should care about what image format is used, it should "just work"

mic006 commented 1 year ago

JPEG and PNG have completely different usage:

For catima, JPEG is better when people take a picture of their card with their camera, but PNG is better when you just download the logo from a website and use it as your card image.

Korb commented 3 months ago

I took one of my cards and saved it in PNG, JPEG, WebP and JPEG 2000 formats with maximum compression, at which the text on the card was readable and the barcode was scanned without errors. Sizes of the resulting files:

WebP (Quality 30) — 19 KB JPEG 2000 (Quality 10) — 38 KB JPEG (Quality 3) — 54 KB PNG (Smallest file size / slowest saving) — 472 KB

Image resolution: 640 × 400 px.

I am concerned that after adding 500+ photos and scans of cards weighing 0.5 GB, they will take up too much space on the smartphone, and my family and I will have to transfer this huge archive to each other when synchronizing.

Korb commented 3 months ago

2024-07-05_20-57-03

The average file weight is 1.45 MB, image sizes range from 321 × 512 to 2048 × 2048 px.

Without differential synchronization capabilities, transferring 740 MB archives between devices using the same card database can be difficult. Not everyone and not always have constant access to unlimited fast Internet. Especially during the vacation period. This archive contains 514 images that could take up less than 10 MB (see my previous post), 70+ times smaller.