mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
[#154] Created the cross-platform unit core_pe.photo in prep for rotation support.
This commit is contained in:
parent
a0809333c1
commit
cc7ccff48e
@ -14,31 +14,24 @@ import re
|
||||
from appscript import app, its, CommandError, ApplicationNotFoundError
|
||||
|
||||
from hscommon import io
|
||||
from hscommon.util import get_file_ext, remove_invalid_xml
|
||||
from hscommon.util import remove_invalid_xml
|
||||
from hscommon.path import Path
|
||||
from hscommon.cocoa.objcmin import NSUserDefaults, NSURL
|
||||
from hscommon.trans import tr
|
||||
|
||||
from core import fs
|
||||
from core import app_cocoa, directories
|
||||
from . import data, _block_osx
|
||||
from .photo import Photo as PhotoBase
|
||||
from .scanner import ScannerPE
|
||||
|
||||
IPHOTO_PATH = Path('iPhoto Library')
|
||||
|
||||
class Photo(fs.File):
|
||||
INITIAL_INFO = fs.File.INITIAL_INFO.copy()
|
||||
INITIAL_INFO.update({
|
||||
'dimensions': (0,0),
|
||||
})
|
||||
HANDLED_EXTS = {'png', 'jpg', 'jpeg', 'gif', 'psd', 'bmp', 'tiff', 'tif', 'nef', 'cr2'}
|
||||
|
||||
@classmethod
|
||||
def can_handle(cls, path):
|
||||
return fs.File.can_handle(path) and get_file_ext(path[-1]) in cls.HANDLED_EXTS
|
||||
class Photo(PhotoBase):
|
||||
HANDLED_EXTS = PhotoBase.HANDLED_EXTS.copy()
|
||||
HANDLED_EXTS.update({'psd', 'nef', 'cr2'})
|
||||
|
||||
def _read_info(self, field):
|
||||
fs.File._read_info(self, field)
|
||||
PhotoBase._read_info(self, field)
|
||||
if field == 'dimensions':
|
||||
self.dimensions = _block_osx.get_image_size(str(self.path))
|
||||
|
||||
|
26
core_pe/photo.py
Normal file
26
core_pe/photo.py
Normal file
@ -0,0 +1,26 @@
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2011-05-29
|
||||
# Copyright 2011 Hardcoded Software (http://www.hardcoded.net)
|
||||
#
|
||||
# This software is licensed under the "BSD" License as described in the "LICENSE" file,
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.hardcoded.net/licenses/bsd_license
|
||||
|
||||
from hscommon.util import get_file_ext
|
||||
from core import fs
|
||||
|
||||
class Photo(fs.File):
|
||||
INITIAL_INFO = fs.File.INITIAL_INFO.copy()
|
||||
INITIAL_INFO.update({
|
||||
'dimensions': (0,0),
|
||||
})
|
||||
# These extensions are supported on all platforms
|
||||
HANDLED_EXTS = {'png', 'jpg', 'jpeg', 'gif', 'bmp', 'tiff', 'tif'}
|
||||
|
||||
@classmethod
|
||||
def can_handle(cls, path):
|
||||
return fs.File.can_handle(path) and get_file_ext(path[-1]) in cls.HANDLED_EXTS
|
||||
|
||||
def get_blocks(self, block_count_per_side):
|
||||
raise NotImplementedError()
|
||||
|
18
qt/pe/app.py
18
qt/pe/app.py
@ -11,10 +11,8 @@ import logging
|
||||
|
||||
from PyQt4.QtGui import QImage, QImageReader
|
||||
|
||||
from hscommon.util import get_file_ext
|
||||
|
||||
from core import fs
|
||||
from core_pe import data as data_pe, __appname__
|
||||
from core_pe.photo import Photo as PhotoBase
|
||||
from core_pe.scanner import ScannerPE
|
||||
|
||||
from ..base.app import DupeGuru as DupeGuruBase
|
||||
@ -24,19 +22,9 @@ from .result_window import ResultWindow
|
||||
from .preferences import Preferences
|
||||
from .preferences_dialog import PreferencesDialog
|
||||
|
||||
class File(fs.File):
|
||||
INITIAL_INFO = fs.File.INITIAL_INFO.copy()
|
||||
INITIAL_INFO.update({
|
||||
'dimensions': (0,0),
|
||||
})
|
||||
HANDLED_EXTS = set(['png', 'jpg', 'jpeg', 'gif', 'bmp', 'tiff', 'tif'])
|
||||
|
||||
@classmethod
|
||||
def can_handle(cls, path):
|
||||
return fs.File.can_handle(path) and get_file_ext(path[-1]) in cls.HANDLED_EXTS
|
||||
|
||||
class File(PhotoBase):
|
||||
def _read_info(self, field):
|
||||
fs.File._read_info(self, field)
|
||||
PhotoBase._read_info(self, field)
|
||||
if field == 'dimensions':
|
||||
try:
|
||||
ir = QImageReader(str(self.path))
|
||||
|
Loading…
x
Reference in New Issue
Block a user