Skip to content

Commit

Permalink
Expand range of image types that can be opened
Browse files Browse the repository at this point in the history
Use a plain black rectangle as a thumbnail for files that Qt can't load.
  • Loading branch information
jim-easterbrook committed Apr 18, 2015
1 parent 46c6938 commit 4614fd0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/photini/__init__.py
@@ -1,5 +1,5 @@
from __future__ import unicode_literals

__version__ = '15.04.0.dev207'
_dev_no = '207'
_commit = '4495410'
__version__ = '15.04.0.dev208'
_dev_no = '208'
_commit = '46c6938'
16 changes: 13 additions & 3 deletions src/photini/imagelist.py
Expand Up @@ -137,6 +137,9 @@ def load_thumbnail(self):
if not self.pixmap:
result = True
self.pixmap = QtGui.QPixmap(self.path)
if self.pixmap.isNull():
self.pixmap = QtGui.QPixmap(200, 150)
self.pixmap.fill(Qt.black)
if max(self.pixmap.width(), self.pixmap.height()) > 400:
# store a scaled down version of image to save memory
self.pixmap = self.pixmap.scaled(
Expand Down Expand Up @@ -280,9 +283,16 @@ def mousePressEvent(self, event):

@QtCore.pyqtSlot()
def open_files(self):
types = []
for ext in QtGui.QImageReader.supportedImageFormats():
types.append('*.' + ext.data().decode('utf_8'))
types = [
'jpeg', 'jpg', 'exv', 'cr2', 'crw', 'mrw', 'tiff', 'tif', 'dng',
'nef', 'pef', 'arw', 'rw2', 'sr2', 'srw', 'orf', 'png', 'pgf',
'raf', 'eps', 'gif', 'psd', 'tga', 'bmp', 'jp2'
]
for fmt in QtGui.QImageReader.supportedImageFormats():
ext = fmt.data().decode('utf_8').lower()
if ext not in types:
types.append(ext)
types = map(lambda x: '*.' + x, types)
path_list = QtGui.QFileDialog.getOpenFileNames(
self, "Open files", self.config_store.get('paths', 'images', ''),
self.tr("Images ({0});;All files (*)").format(' '.join(types)))
Expand Down

0 comments on commit 4614fd0

Please sign in to comment.