Writing multipage TIFF with Python

In my opinion, the most full-featured and easy to use method of writing multipage TIFF (all at once or via appending) is via tifffile.

You can also use the freeimage plugin to SciPy as one method to write multipage TIFF images, or libtiff.

For tifffile

just download and use tifffile.py  or type

pip install tifffile

For FreeImage (recommend tifffile instead)

On Windows you might see the error:
RuntimeError: Could not find a FreeImage library

On Linux you might see the error:
freeimage had a problem: Could not find a FreeImage library in any of…

To fix this on Windows, download the FreeImage DLL
Then extract the file
to the following directory (assuming you’re using Anaconda Python)

To fix this on Linux, type
sudo apt-get install libfreeimage3

Example code (assuming you have image stored in C-ordered 3-D array images):

from skimage.io._plugins import freeimage_plugin as freeimg

or try this example test code



Converting AVI to grayscale PNG for easier analysis/viewing

An example of a large pixel-count AVI is the Dahlgren et al 2013 article on auroral bursts. This was taken with a 2560×2160 Andor Neo sCMOS camera and this video has 351 frames.

You can try this process to keep in a more widely-compatible MJPEG motion JPEG AVI format, or alternatively you can convert each frame to PNG and use Irfanview or your favorite image browser to flick back and forth between frames. The conversion occurs using ImageMagick (which itself calls ffmpeg in this case).

convert -verbose CMOSvideoshorter_halfspeed.avi -type Grayscale CMOSvideo_%03d.png

in this example, 351 PNGs will be created of about 1MB size each.

Cinepak videos in ImageJ

If someone has sent you an AVI file with Cinepak compression, you may find that ImageJ/FIJI and other contemporary software cannot read the AVI file.

There are two plugins that attempt to address this for ImageJ:



But I found neither of them to work for me on the particular AVI Cinepak video I was given.

Instead, I used FFMPEG to convert to a more modern widely-compatible Motion JPEG format by typing:
ffmpeg -i video1990s.avi -vcodec mjpeg -qscale 1 test.avi

If you need no loss, you can do uncompressed AVI, but note the output file size could be a factor of 10 larger than the Cinepak version:

ffmpeg -i video1990s.avi -vcodec rawvideo out.avi

You can compress to LOSSLESS FFV1 by typing:

ffmpeg -i video1990s.avi -vcodec ffv1 out.avi

You can also convert the AVI to a series of PNG images.

AIDA tools

For those interested in working with data from ASK/ALIS or just seeing how some interesting 3D tomography works, there is a Matlab toolbox at:


or using Subversion, type at Terminal:
svn co "https://aniara.irf.se/svn/AIDA_tools/trunk" AIDA_tools

1) cp ~/AIDA_tools/AIDA_startup.m ~/matlabTools/
(or wherever you keep your frequently used scripts)
2) edit this ~/matlabTools/AIDA_startup.m file and make the following changes:
Line 3: AIDA_root = fullfile(‘~’);

then look farther down in the AIDA_startup.m file and add these “min” functions:

% Its version dependent functions, currently M 6.xx and M 7.xx

% Its version dependent functions, currently M 6.xx and M 7.xx

3) I comment out the “warning off” on line 17 of AIDA_startup.m, I like to know Matlab is complaining.

ImageMagick suggested compile options

These options were used to compile ImageMagick 6.7.9-3 and 6.8.0-4.

Before compiling, I urge you to ensure libjasper-dev is installed, so that you can manipulate JPEG2000 images. Try typing:
sudo apt-get install libjasper-dev libpng-dev

Then, type:

./configure --with-modules --with-gslib --with-wmf --with-perl --with-rsvg --with-gvc

Note: you can add HDRI http://www.imagemagick.org/script/high-dynamic-range.php
by adding this option above:

Note: To see if those options actually work, scroll back up about halfway through the console output to see if the compiler could find the modules you’re interested in. Otherwise, you won’t actually have the requested features.

Then do the usual
make install

Note: if you get an error like:

libMagickCore.so.6: cannot open shared object file: No such file or directory
when trying to run ImageMagick, try:

whereis libMagickCore.so.6
assuming you find it in /usr/local/lib, type:
sudo ldconfig /usr/local/lib