I have a 1.8GB TIF image that I'm trying to open on my machine with Ubuntu 18.04.1 LTS. I have 8GB of RAM and 2GB of swap space. However, I can't open the image on the stock Gnome Image Viewer (says "Dimensions of TIFF image too large"), or Shotwell (says "Photo source file missing: [path to the file]"), or Gimp (bugs out), or on my Windows 7 VM with 4GB of RAM (says too little RAM even though it had over 2.5GB free), or feh, which behaves like this:
$ feh DO_NOT_OPEN.tif
TIFFFetchNormalTag: Warning, Incompatible type for "RichTIFFIPTC"; tag ignored.
feh WARNING: DO_NOT_OPEN.tif - No Imlib2 loader for that file format
feh: No loadable images specified.
See 'man feh' for detailed usage information
Is there any way to open this image on Ubuntu?
(For the curious, the image is this one. I named it like that because the first time i tried to open it crashed my computer ¯_(ツ)_/¯ )
Best Answer
Why can't I open the image in any viewer?
The issue is probably RAM and/or CPU.
The TIFF image is LZW-compressed. When an application wants to display it, it needs to uncompress the image first. And that's where RAM and CPU come into play. Furthermore, depending on the application, there may be buffers that also need RAM.
I did some (non-scientific) experiments and noticed differences between applications in three phases: when loading the image, after loading the image, when zooming in.
Shotwell took up to 5GB of RAM while opening the file and then dropped to 2GB. When I zoomed in, it went up to 7GB.
Gimp went up to 5GB and stayed there when viewing the image and zooming in. The RAM usage gradually increased when editing the image.
GwenView went up to 3.8GB while loading and dropped to 2GB afterwards. When zooming in, it went up to 2.7GB.
Your best bet is trying GwenView (the default image viewer in Kubuntu, but can be installed in stock Ubuntu as well).
What options do I have if the image is way too big for RAM?
In general, if the image is too big to fit into RAM, you can split it using
convert
which is part of theimagemagick
package.You need to increase the default limits which are defined in
/etc/ImageMagick-6/policy.xml
(the number 6 may change in future versions). You need to adjust the maximum size in pixels, which are defined in the following lines:KP means KiloPixels, i.e. thousand pixels. In your case, the image has 40000x12788 pixels, so you only need to change the width to something greater than 40KP, e.g. 41KP.
Additionally, you need to increase the maximum disk space:
to something reasonable like 10GiB.
To split the image into 5x3 parts and produce one file per part, use the following command:
For more information about
convert
, see man convert or take a look at the documentation.Maybe a bit off topic, but here's a quick&dirty bash script that tiles an image and creates an html page that displays an overview where you can click on a tile to open it in full resolution. Save it as e.g.
tile_image.sh
and invoke it like./tile_image.sh originalImage tilesX tilesY
, where tilesX is the number of tiles horizontally and tilesY is the number of tiles vertically.