description from jpeg
This commit is contained in:
@@ -9,7 +9,7 @@ from imagelist2.db import DB, sqlite_sqrt, sqlite_square
|
|||||||
from imagelist2.image import ImageMeasure, is_image_extension
|
from imagelist2.image import ImageMeasure, is_image_extension
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
__version__ = "0.0.2"
|
__version__ = "0.0.3"
|
||||||
SQLFILE = "image-list.sqlite"
|
SQLFILE = "image-list.sqlite"
|
||||||
# IMGMATCH = re.compile("|".join([".*\." + x + "$" |.*\.jpeg$|.*\.png$|.*\.gif$|.*\.tif$", re.I)
|
# IMGMATCH = re.compile("|".join([".*\." + x + "$" |.*\.jpeg$|.*\.png$|.*\.gif$|.*\.tif$", re.I)
|
||||||
BADDIRS = ["_tn", "_med", ".tn", ".med"]
|
BADDIRS = ["_tn", "_med", ".tn", ".med"]
|
||||||
@@ -124,13 +124,14 @@ class ImageList:
|
|||||||
continue
|
continue
|
||||||
image = ImageMeasure(filename)
|
image = ImageMeasure(filename)
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"""INSERT INTO data(hash,portrait,width,height)
|
"""INSERT INTO data(hash,portrait,width,height,description)
|
||||||
VALUES(?,?,?,?)""",
|
VALUES(?,?,?,?,?)""",
|
||||||
(
|
(
|
||||||
row[0],
|
row[0],
|
||||||
image.get_portrait(),
|
image.get_portrait(),
|
||||||
image.get_width(),
|
image.get_width(),
|
||||||
image.get_height(),
|
image.get_height(),
|
||||||
|
image.get_description()
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if i % 50 == 0:
|
if i % 50 == 0:
|
||||||
|
|||||||
@@ -111,6 +111,12 @@ class ImageMeasure:
|
|||||||
self.portrait = self.height >= self.width
|
self.portrait = self.height >= self.width
|
||||||
return self.width, self.height, self.portrait
|
return self.width, self.height, self.portrait
|
||||||
|
|
||||||
|
def get_description(self):
|
||||||
|
if self.description is None:
|
||||||
|
self.description = read_image_comment(self.filename)
|
||||||
|
return self.description
|
||||||
|
|
||||||
|
|
||||||
def get_image(self, image_type="numpy"):
|
def get_image(self, image_type="numpy"):
|
||||||
|
|
||||||
if self.image is None:
|
if self.image is None:
|
||||||
@@ -227,3 +233,8 @@ def read_image_size(fname):
|
|||||||
"""Just reading the size is faster with PIL"""
|
"""Just reading the size is faster with PIL"""
|
||||||
im = Image.open(fname)
|
im = Image.open(fname)
|
||||||
return im.width, im.height
|
return im.width, im.height
|
||||||
|
|
||||||
|
def read_image_comment(fname):
|
||||||
|
"""Just reading the comment with PIL"""
|
||||||
|
im = Image.open(fname)
|
||||||
|
return im.info.get('comment','')
|
||||||
|
|||||||
Reference in New Issue
Block a user