/usr/share/doc/python-pyexiv2/examples/pyqt-example.py is in python-pyexiv2 0.3.2-5ubuntu4build6.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# ******************************************************************************
#
# Copyright (C) 2007-2010 Olivier Tilloy <olivier@tilloy.net>
#
# This file is part of the pyexiv2 distribution.
#
# pyexiv2 is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# pyexiv2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyexiv2; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
#
# Author: Olivier Tilloy <olivier@tilloy.net>
#
# ******************************************************************************
import sys
from PyQt4 import QtGui
from pyexiv2 import ImageMetadata
if __name__ == '__main__':
"""
Example of how to combine PyQt4 and pyexiv2 to display thumbnail data.
Minimalistic example of how to load and display with PyQt the thumbnail data
extracted from an image.
The path to the image file from which the thumbnail data should be extracted
should be passed as the only argument of the script.
It is of course assumed that you have PyQt4 installed.
"""
if (len(sys.argv) != 2):
print 'Usage: ' + sys.argv[0] + ' path/to/picture/file/containing/jpeg/thumbnail'
sys.exit(1)
app = QtGui.QApplication([])
# Load the image, read the metadata and extract the thumbnail data
metadata = ImageMetadata(sys.argv[1])
metadata.read()
previews = metadata.previews
if not previews:
print "This image doesn't contain any thumbnail."
sys.exit(1)
# Get the largest preview available
preview = previews[-1]
# Create a pixmap from the thumbnail data
pixmap = QtGui.QPixmap()
pixmap.loadFromData(preview.data, 'JPEG')
# Create a QT label to display the pixmap
label = QtGui.QLabel(None)
label.setPixmap(pixmap)
# Show the application's main window
label.show()
sys.exit(app.exec_())
|