Affinity Wine DocumentationAffinity Wine Documentation
Guide
Contributing
  • To-Do
  • License
  • Analytics
Source
Guide
Contributing
  • To-Do
  • License
  • Analytics
Source

Generating thumbnails on Gnome

This is a little guide to show how thumbnail-generation for Affinity files (.afphoto, .afdesign, .afpub) can be achieved. With the Nautilus file manager, to get thumbnails working for a specific file type you usually need the following:

  • A mime-type definition (in this case a .xml containing information about which file extension is associated with which mime-type and which icon it should use by default)
  • A .thumbnailer file telling the system which thumbnail-generator to use for each mime-type
  • A thumbnail-generator which can create a thumbnail for a given file

In this case all files needed are available in this repo. Since Serif uses the same format to put thumbnails into their files (they simply put a PNG of the thumbnail in the Affinity-document which can then be extracted using a simple script) we only need one thumbnail-generator script that can be called for all three file types.

The script requires python3. You can try the script for yourself by calling it like so

./affinity-thumbnailer.py [input-file.afphoto/.afdesign/.afpub] output.png

This should create a png containing the image data for the thumbnail of the file you put into it.

If the script says it could not extract the thumbnail that probably means you're not saving thumbnails with your files.

To enable thumbnails in Affinity you need to go to Edit > Settings > General and check Save thumbnails with documents. (After that only documents that get saved again will contain thumbnails)

Once you made sure that calling this script can extract the thumbnail of an Affinity-document, you can continue actually installing the necessary files:

Installing

  • Clone this repo in your $HOME/Documents directory and cd into thumbnails:
git clone https://codeberg.org/wanesty/affinity-wine-docs.git $HOME/Documents/affinity-wine-docs
cd $HOME/Documents/affinity-wine-docs/thumbnails/
  • Copy affinity-thumbnailer.py into a $PATH directory, as with rum, we'll use /usr/local/bin/:
cp affinity-thumbnailer.py /usr/local/bin/
  • Copy the three .xml files under mime-definitions into $HOME/.local/share/mime/packages:
cp mime-definitions/*.xml $HOME/.local/share/mime/packages/
  • Copy the three .thumbnailer files under thumbnailers into $HOME/.local/share/thumbnailers:
cp -r thumbnailers/ $HOME/.local/share/thumbnailers
  • Update the mime-type database:
update-mime-database $HOME/.local/share/mime
  • Log out and log back in.

  • You might need to remove the current thumbnail cache:

rm -r ~/.cache/thumbnails

If you now open your file manager again you should see that all your Affinity files should have thumbnails. The ones where the thumbnail-generator could not extract a thumbnail should revert back to a default icon. This default icon is defined in the .xml files containing the mime-type. Currently it assumes that your icon pack has icons called affinity-photo, affinity-designer and affinity-publisher. Likely your icon pack does not have these icons, so you can specify your own by simply replacing the names of these icons in the .xml files.

Troubleshooting

If you cannot get thumbnails to work for any files at all here are some hints that might help:

  • Make sure you activate thumbnails being saved with documents in the settings of your Affinity programs and saved all previous files at least once after.
  • Make sure you can run the thumbnail-generator script and extract a thumbnail manually.
  • Make sure that the thumbnail-generator is actually executable inside the /usr/bin directory; You should be able to call it by simply opening a new terminal and typing affinity-thumbnailer.py.
  • Check if you placed all the necessary files in the right directories, updated your mime-database, removed all thumbnails and restarted your file manager completly.

If you're still having issues feel free to open an issue in this repository or ask in the Linux thread in the Affinity forum! 😃

Edit this page on Codeberg
Last Updated:
Contributors: wanesty