mirror of
https://github.com/Kilian/Trimage.git
synced 2026-01-25 17:48:41 -05:00
Simplify way to check if an image is valid
determinetype functions has some defaults
This commit is contained in:
parent
f7531a1095
commit
13f43bfa2f
1 changed files with 2 additions and 12 deletions
|
|
@ -16,7 +16,6 @@ from PyQt5.QtCore import *
|
|||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtWidgets import *
|
||||
from filesize import *
|
||||
from imghdr import what as determinetype
|
||||
|
||||
from queue import Queue
|
||||
from ThreadPool import ThreadPool
|
||||
|
|
@ -398,23 +397,14 @@ class Image:
|
|||
self.reset()
|
||||
self.fullpath = fullpath
|
||||
if path.isfile(self.fullpath) and access(self.fullpath, WRITEABLE):
|
||||
self.filetype = determinetype(self.fullpath)
|
||||
if self.filetype in ["jpeg", "png"]:
|
||||
self.filetype = path.splitext(self.fullpath)[1]
|
||||
if self.filetype in [".jpeg", ".jpg", ".png"]:
|
||||
oldfile = QFileInfo(self.fullpath)
|
||||
self.shortname = oldfile.fileName()
|
||||
self.oldfilesize = oldfile.size()
|
||||
self.icon = QIcon(self.fullpath)
|
||||
self.valid = True
|
||||
|
||||
#def _determinetype(self):
|
||||
# """ Determine the filetype of the file using imghdr. """
|
||||
# filetype = determinetype(self.fullpath)
|
||||
# if filetype in ["jpeg", "png"]:
|
||||
# self.filetype = filetype
|
||||
# else:
|
||||
# self.filetype = None
|
||||
# return self.filetype
|
||||
|
||||
def reset(self):
|
||||
self.failed = False
|
||||
self.compressed = False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue