summaryrefslogtreecommitdiff
path: root/dedup/image.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2021-12-31 15:45:33 +0100
committerHelmut Grohne <helmut@subdivi.de>2021-12-31 15:45:33 +0100
commitf3ea68482e6c01053cb202573d953e8a2e89529f (patch)
tree4c08f6e5a99bbe5131c0949e7f97cc44cf4a2cbd /dedup/image.py
parentf2eda3ba74e5bc5613e84381ebd8bfd343e1c8cc (diff)
parent5b359b10053cbade539246eec26e86b44793ca40 (diff)
downloaddebian-dedup-f3ea68482e6c01053cb202573d953e8a2e89529f.tar.gz
Merge branch master into branch multiarchhints
Among other things, this drops Python 2.x support.
Diffstat (limited to 'dedup/image.py')
-rw-r--r--dedup/image.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/dedup/image.py b/dedup/image.py
index 314eb44..91321f4 100644
--- a/dedup/image.py
+++ b/dedup/image.py
@@ -3,7 +3,7 @@ import struct
import PIL.Image
-class ImageHash(object):
+class ImageHash:
"""A hash on the contents of an image data type supported by PIL. This
disregards mode, depth and meta information. Note that due to limitations
in PIL and the image format (interlacing) the full contents are stored and
@@ -69,9 +69,14 @@ class ImageHash(object):
self.content.seek(pos)
return "%s%8.8x%8.8x" % (hashobj.hexdigest(), width, height)
+ @property
+ def name(self):
+ return self.name_prefix + self.hashobj.name
+
class PNGHash(ImageHash):
"""A hash on the contents of a PNG image."""
+ name_prefix = "png_"
def detect(self):
if self.content.tell() < 33: # header + IHDR
@@ -86,6 +91,7 @@ class PNGHash(ImageHash):
class GIFHash(ImageHash):
"""A hash on the contents of the first frame of a GIF image."""
+ name_prefix = "gif_"
def detect(self):
if self.content.tell() < 10: # magic + logical dimension