Mastodon: keeping the Metadata
preamble
There's a lot of reasons why you would want to remove metadata from the media you post on Mastodon, but the thing is there are also reasons to keep them, and not giving a choice is somewhat similar to what shitty governments are doing : "we consider that you're too stupid to learn and do anything, so let us take care of your own good." That is precisely what makes people ignorant, and is often done for specific agenda, not people.
Anyway, considering that managing metadata is among the easiest thing to do, it's not a good thing to remove them, because even if anyone can remove them manually before posting, no one can add them afterwards if they are automatically removed.
I won't go into details on the reasons why it's better to remove or keep them, as defenders of either ways might be reluctant to listen to any arguments.
So, if like me you think that metadata shouldn't be automatically removed and you're managing your own instance, here's what to do :
Keeping metadata tweaks:
Mastodon < v4.6
You need to tweak the following file :
~/live/app/models/media_attachment.rb
by modifying this list :
GLOBAL_CONVERT_OPTIONS = {
all: '-quality 90 +profile "!icc,*" +set date:modify +set date:create +set date:timestamp -define jpeg:dct-method=float',
}.freezeinto that :
GLOBAL_CONVERT_OPTIONS = {
all: '-quality 90 +set date:modify +set date:create +set date:timestamp -define jpeg:dct-method=float',
}.freezeThat way every metadata from your file will be retained. There's one more thing you need to do to be sure that it will work : disabling the use of VIPS, as this method only works with the imagemagic library. So, in your .env.production file, you need to set
MASTODON_USE_LIBVIPS=false
Restart Mastodon, and you're done :)
Mastodon >= v4.6
Starting from mastodon v4.6, VIPS is now mandatory and it's not possible anymore to use imagemagic, so the previous tweak won't work. Now you need to tweak what's used by libvips. Unfortunately, that's a little less handy than the previous method, but it still works. So, the file that needs to be tweaked is this one :
~/live/lib/paperclip/vips_lazy_thumbnail.rb
And this time, it's not something that needs to be removed but something that needs to be added, as the default configuration removes everything besides icc color profiles. At the beginning of the file, there's a list of value in a variable named ALLOWED_FIELDS. That's the list of values corresponding to metadata that won't be erased. So you'll have to add what you want to keep in this list.
Here's a reference page of values that might help you : https://www.libvips.org/API/current/libvips-header.html
And if you're always setting the same kind of metadata in your media files, then you can use the following command with the cli of your mastodon's instance server to check the name of the values you need to add :
vipsheader -a yourmediafile.jpgThen note the value names in the output that match the values you want to be kept, and finally, change the ALLOWED_FIELDS list, from :
ALLOWED_FIELDS = %w(
icc-profile-data
).freezeto something that resemble that, but with your own values choices :
ALLOWED_FIELDS = %w(
icc-profile-data
xmp-data
iptc-data
exif-data
exif-ifd0-Artist
exif-ifd0-ImageDescription
).freezeSome kind of metadata can't be retained no matter what you do because they are not recognized (yet) by libvips, but tweaking this list still allows to keep a good bunch of them.
Once it is done, then restart mastodon and you're all set !
Manually handle metadata before posting.
Even if you want to keep the metadata, it does not mean that you do not want to have the option to remove them. The good news is : you never needed any online service to do that for you. There are two simple "methods".
Either you don't care about metadata and don't want them at all in the first place, or you want to keep them for yourself and want to remove them before posting.
-- For the first case (don't want them at all), that's the easiest way : if your concern is about the pictures you're taking with your phone or camera, then dig in the manual of your device or software and search for metadata. There's a good chance that there are settings to set or remove them. Once it's done, your files won't get any metadata from your device, so there's won't be anything to remove.
If you don't find any settings, which would be surprising, you could start by disabling the GPS on your device because that's among the most private metadata your can find in media files, unless you're continuously lost and need your GPS 24/7... but if that's the case, maybe you have bigger problems than metadata not being erased.
Same goes for the software that you're using : metadata are often optional, and the potentially personal values won't set themselves unless you do it. So don't if you don't want them :)
-- Now, if you want to set metadata for yourself, but remove them before sharing your files, then you need a software to remove them. And there are plethora of those that can easily do that. Here are a few examples :
On android
- Scrambled Exif
- Exif eraser
- Image pipe
- MetaPurge
- XnConvert
- etc.
On Desktop
- XnConvert (linux/win/mac)
- XnView (linux/win/mac)
- etc.
Self Hosted
- PrivMeta
- etc.
Surely there are some options for ios users, but I've not searched for it.
Some OS file managers can also read and modify those kind of things, so maybe you don't even need another software to handle that. That's really something that is quite easy to do, so there's no reason to deprive everyone from the right to set some data along with their media file, in the name of those who don't want to do the "effort" to manage it themselves in the first place.
If Mastodon devs were honest, they would allow metadata by default, and add a warning with the upload media popup, like they are already doing for alt text...