Lemmy Guides

cross-posted from: https://linkage.ds8.zone/post/523771

Before posting an image to the fedi, I want to be mindful about the network burden it will cause. I’m only uploading the image once but potentially thousands of people could end up downloading it.

If it’s a color image, then JPG is typically best. This #ImageMagick command reduces the filesize quite a bit, trading off quality:

  $ convert "$original_image_file" \
    +dither \
    -posterize 8 \
    -sampling-factor 4:2:0 \
    -strip \
    -quality 75 \
    -interlace Plane \
    -gaussian-blur 0.05 \
    -colorspace RGB \
    -strip \
    smaller_file.jpg

If it’s a pic of a person, this processing will likely be a disaster. But for most things where color doesn’t matter too much, it can be quite useful. Play with different -posterize values.

If you can do with fewer pixels, adding a -resize helps.

  $ convert "$original_image_file" -resize 215x smaller_file.jpg

If you can get away with black and white, jpeg is terrible. Use PNG instead. E.g.

  $ convert "$original_image_file" -threshold 30% -type bilevel smaller_file.png

For privacy, strip the metadata

The ImageMagick -strip option supposedly strips out metadata. But it’s apparently not thorough because the following command yields a slightly smaller file size:

  $ exiftool -all= image.jpg

What else?

Did I miss anything? Any opportunities to shrink images further? In principle the DjVu format would be more compact but it’s not mainstream and apparently not accepted by Lemmy.

I've had better luck with webp as far as minimizing size while preserving acceptable quality.

Not sure what other apps do this (they really, really should!), but Tesseract can optionally pre-convert a pasted/uploaded image to webp with a user-selectable quality profile. When I ran an instance, I had a very low (250 KB) upload limit on images, and the pre-conversion made it a non-issue for all but the largest images.

That also works to strip out metadata, though I believe pict-rs (Lemmy's image "subsystem") will also strip out metadata (don't quote me on this and do correct me if I'm wrong).

Edit: Also, whoever runs linkage.ds8.zone has Anubis setup wrong. The /api path should not be behind Anubis.

2 replies

lemmy_migrate to import/export subscribed communities

2y 10mon ago by lemmy.world/u/mintycactus in lemmyguides@lemmy.today from github.com
743

Lemmy Firefox Extensions

2y 10mon ago by lemmy.today/u/1984 in lemmyguides@lemmy.today from addons.mozilla.org
204

Set sort type to top 6 hours

2y 10mon ago by lemmy.today/u/1984 in lemmyguides@lemmy.today
3115

Lemmy Mobile Clients

2y 10mon ago by lemmy.today/u/mrmanager in lemmyguides@lemmy.today from lemmy.today
306

How to subscribe to Remote Communities

2y 10mon ago by lemmy.today/u/mrmanager in lemmyguides@lemmy.today from lemmy.today
587