PDA

View Full Version : Loading TIF images in Ubuntu



drhex
11th June 2015, 07:06
I have some problems loading TIF images using Qt.

Googling gave me this:
http://doc.qt.io/qt-5/qtimageformats-index.html

The actual coding and decoding of the file format is done by a codec library. The codec can be Qt or third party code. In case of a third party codec, the build process will look for it among the system libraries. If not found, it may fall back on using a bundled copy (in src/3rdparty).

On my own machine (Linux Mint 17.1, Qt 5.3.2 compiled from source), the return value of
QImageReader::supportedImageFormats() includes "tif" and "tiff". and consequently such images load fine.

On a friend's machine (Ubuntu 14.04, Qt 5.2.1 that came with the installation), supportedImageFormats() does not include "tif". However,


locate libtiff on the command prompt shows
/usr/lib/x86_64-linux-gnu/libtiff.so.5
/usr/lib/x86_64-linux-gnu/libtiff.so.5.2.0

As per the quote above, I expected Qt to find the codec "among the system libraries". What need to be done to ensure that?

wysota
11th June 2015, 07:30
First of all check if your friend's Qt installation includes qtiff plugin like your does.

$ ls -1 /usr/lib/x86_64-linux-gnu/qt4/plugins/imageformats

libqgif.so
libqico.so
libqjpeg.so
libqmng.so
libqsvg.so
libqtga.so
libqtiff.so

drhex
11th June 2015, 09:35
Yes, he gets the exact same list of libraries, including libqtiff.so

wysota
11th June 2015, 11:01
Does running ldd on libqtiff.so report any missing dependencies? Make sure you are checking the appropriate Qt installation!

drhex
12th June 2015, 07:35
>ldd /usr/lib/x86_64-linux-gnu/qt4/plugins/imageformats/libqtiff.so
linux-vdso.so.1 => (0x00007fff287c9000)
libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f76882b7000)
libQtGui.so.4 => /usr/lib/x86_64-linux-gnu/libQtGui.so.4 (0x00007f7687604000)
libQtCore.so.4 => /usr/lib/x86_64-linux-gnu/libQtCore.so.4 (0x00007f768711e000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f7686e1a000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f7686c04000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f768683e000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f768661c000)
libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007f768640e000)
libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007f76861b8000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f7685f9f000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7685c99000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f7685a5c000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f768583e000)
libaudio.so.2 => /usr/lib/x86_64-linux-gnu/libaudio.so.2 (0x00007f7685626000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f768531d000)
libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f76850f7000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f7684e54000)
libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f7684c02000)
libSM.so.6 => /usr/lib/x86_64-linux-gnu/libSM.so.6 (0x00007f76849fa000)
libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6 (0x00007f76847de000)
libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007f76845cd000)
libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f76843c3000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f76841b1000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f7683e7b000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7683c77000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f7683a6f000)
/lib64/ld-linux-x86-64.so.2 (0x00007f768874d000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f7683844000)
libXt.so.6 => /usr/lib/x86_64-linux-gnu/libXt.so.6 (0x00007f76835de000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f76833d9000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f768319b000)
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f7682f93000)
libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f7682d8d000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f7682b6e000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f7682967000)

It seems they're all there.
My simple testprogram (which doesn't print "tif") looks like so:



#include <QApplication>
#include <QImageReader>
#include <QList>

int main( int argc, char **argv )
{
QApplication app( argc, argv );

QList<QByteArray> foo = QImageReader::supportedImageFormats();
foreach (QByteArray b, foo)
{
qDebug("%s", qPrintable(QString(b)));
}

exit(0);
}

How come libqtiff resides in qt4's plugin directory rather than in qt5's ?

I tried running strace (a program that logs all syscalls with arguments and return values) on the test program above to possibly get more detailed error-info. The string "tif" was nowhere to be found in the log. There was plenty of references to the qt5/plugin directories, but none to the qt4/plugin directories.
In desperation, I made a symlink to qt4/plugins/imageformats/libqtiff.se in the corresponding qt5 directory, but to no avail.

wysota
12th June 2015, 08:36
How come libqtiff resides in qt4's plugin directory rather than in qt5's ?
Apparently you are checking Qt4 installation and not Qt5 :)

Your friend probably doesn't have the qt5-image-formats-plugins package installed.

drhex
12th June 2015, 12:27
Confirmed. Installing qt5-image-formats-plugins fixed the issue.