Skip to content

Tools and formats

JPEG, PNG, WebP and GIF, also animated (APNG for PNG), TIFF (every page, and grey TIFFs of floats from science stretched to show), BMP, ICO (every size), QOI, PNM, Radiance HDR (tone-mapped), Zeiss LSM and .gel scans, camera RAW files through their embedded preview, and HEIC, AVIF and video through ffmpeg, JPEG XL and SVG, as the packages are built.

Both are small desktop files in a folder of your own, which name a program. Glimt runs it directly, never through a shell, with each file as an argument of its own, so a file named $(rm -rf ~).jpg stays a name.

  • Tools (~/.local/share/glimt/tools) run a program on the selected files from Edit → Tools: rotate them, send them somewhere, or describe them with a model on your own computer. One that is still running, such as a script that hangs, is ended with Stop in the same menu, with what it started. Glimt's examples/tools also has read-aloud.desktop, which reads the alt text of the selected images aloud (speech-dispatcher's spd-say), or their comment, or their name, for those who see poorly but use no screen reader. A tool can take only some types of files: see Writing a tool.
  • Formats (~/.local/share/glimt/formats) teach Glimt a format it does not read itself. The program gets a file and writes the image to its standard output; Glimt then lists, shows and makes thumbnails of such files as of any other.

Glimt also reads the system's folders, /usr/share/glimt/tools and /usr/share/glimt/formats (in each folder of $XDG_DATA_DIRS). A desktop file in your own folder hides one of the same name there.

Glimt no longer reads the folders ~/.local/share/glimt/plugins and decoders of older versions, nor the header [Glimt Decoder], and says so at each start and in glimt --check-config while they hold desktop files: move those into tools and formats, with the header [Glimt Format]. The changelog lists the examples renamed since.

They are in examples/formats in Glimt's source, and each is tested in Glimt's release tests.

Desktop file Formats Field Needs
dicom.desktop DICOM (.dcm), also compressed, in the window the file names medicine, dentistry python3-pydicom, python3-gdcm
nifti.desktop NIfTI (.nii, .nii.gz): the middle axial slice brain MRI, fMRI python3-nibabel
openslide.desktop Whole-slide images (.svs, .ndpi, .mrxs, .scn …) pathology python3-openslide
bioformats.desktop Zeiss .czi, Leica .lif, Nikon .nd2, Olympus .oib/.oir and more (ICS too, once you add ics;ids to its Extensions) microscopy Java and Bio-Formats' bftools
mrc.desktop MRC (.mrc, .map, .rec …): a micrograph or the middle section cryo-EM, structural biology python3-mrcfile
fits.desktop FITS (also .fits.fz), with astronomers' zscale stretch astronomy, solar physics python3-astropy
hdf5.desktop HDF5, NetCDF-4, NeXus (.h5, .nc, .nxs): the largest dataset of two or more dimensions climate, physics, satellites python3-h5py
jpeg2000.desktop JPEG 2000 (.jp2, .j2k, .j2c, .jpf, .jpx) archives, libraries ffmpeg
photoshop.desktop Photoshop (.psd, .psb) as saved design, architecture ImageMagick
tga.desktop, exr.desktop TGA, OpenEXR renderings games, 3D ImageMagick
xcf.desktop GIMP's own files, their layers put together design ImageMagick
fits-imagemagick.desktop, dicom-imagemagick.desktop FITS and DICOM through ImageMagick alone astronomy, medicine ImageMagick

To use them, copy those you need with the script a desktop file names (glimt-fits for fits.desktop). Take one of each pair: fits.desktop or fits-imagemagick.desktop, dicom.desktop or dicom-imagemagick.desktop. With both, the one whose name comes first without ".desktop" takes the files (fits before fits-imagemagick), also on a computer without the Python modules it needs.

The .deb and .rpm install them in /usr/share/doc/glimt/examples/formats, and the tar.gz has them in examples/formats:

Terminal window
mkdir -p ~/.local/share/glimt/formats
cd /usr/share/doc/glimt/examples/formats
cp jpeg2000.desktop fits.desktop glimt-fits ~/.local/share/glimt/formats/

Restart Glimt, and those files show in the list as images do. A format whose program is missing shows its error where the image would be.

They are for a quick look, not for measuring: the values are stretched to grey (between the 1st and 99th percentile, or zscale for FITS), and the scripts read only the slice or level they show. DICOM files without an ending, as many PACS exports are, are not listed: give them .dcm. DICOM and NIfTI files can hold patient data: Glimt and its formats only show the picture, print or keep no name, ID or other field, and send nothing anywhere.

[Desktop Entry]
Type=Application
Name=Open in darktable
Exec=darktable %F
MimeType=image/x-canon-cr2;image/x-nikon-nef;image/x-adobe-dng;
  • Exec: the command. %f runs it once for each file, %F once for all of them, and without either it runs once in the folder. %f may stand inside a word, as in --input=%f, but not inside "quotes": see %f and quotes. A program next to the desktop file is found there.
  • MimeType (optional): the tool gets only the selected files of these types, and Glimt says how many it leaves out. image/* takes every image. The types are shared-mime-info's own names, not their aliases or parent types.
  • New tools show after a restart. In a Flatpak they run on the host, which needs a permission once: see the FAQ.
[Glimt Format]
Name=JPEG 2000
Extensions=jp2;j2k;j2c;jpf;jpx
Exec=ffmpeg -v error -protocol_whitelist file -format_whitelist j2k_pipe -f j2k_pipe -i %f -frames:v 1 -f image2pipe -vcodec ppm -
  • The group header is [Glimt Format]. A desktop file with the old header, [Glimt Decoder], is no longer read since 0.96.0, and Glimt says so.
  • Extensions: the file endings it takes, separated by ;; an ending may have two parts, as nii.gz. A format Glimt reads itself is never given to an added format, and when two take the same ending, the one whose file name comes first without ".desktop" does.
  • Exec: the command. %f is the file's absolute path, as one argument; it may stand inside a word, as ImageMagick's %f[0] for a file's first frame. %% is a %, so %%f is the text %f. The other % codes are kept for later, so do not use them. A %f only inside "quotes" is not the file, and such a format is not loaded: see %f and quotes. A program next to the desktop file is found there, so a format can bring its own script.
  • The program writes the image to its standard output, as PNM, PNG, TIFF or any other format Glimt reads. It has 30 seconds and may write at most 512 MB; it is stopped after that, with everything it started. It may take at most 4096 MB of memory, which Preferences → Memory and CPU can raise (the setting added_format_memory_mb), for Java with a large heap; the program finds the limit in GLIMT_FORMAT_MEMORY_MB, and one that runs out is told so, with the limit.
  • New formats are seen after a restart. In a Flatpak they run on the host, which needs a permission once: see the FAQ.

A %f inside a "quoted" word stays as it is, as the desktop entry specification says, so a file's name never becomes part of a shell script's text: a downloaded file named x$(command).jpg would run the command. Since 0.80, a format whose %f is only inside quotes, such as sh -c "convert %f ppm:-", is not loaded, and a tool written that way gets no files; Glimt says which at start and in glimt --check-config. Give %f as a word of its own, and read it in the script as "$1":

Exec=sh -c "convert \"$1\" ppm:-" sh %f

Which formats go into Glimt, and which are added

Section titled “Which formats go into Glimt, and which are added”

A format is built into Glimt when the image library Glimt already uses reads it, with no new dependency: BMP, ICO, QOI and PNM came in that way, with a few lines each. A format that needs a large library, a library in C, or a program of its own becomes an added format, so Glimt stays small and fast for everyone, and those who need FITS or DICOM add one file. A format that works well is welcome in Glimt's examples/formats: send a pull request with the desktop file, a line on what it needs, and a test in tools/release-tests/tests.sh.