added small spaces before first row of images to stop squishing into navbar, added flipping / made that work, and now show thumbnail after rotation/flip is finished - all works, and removed debugs

This commit is contained in:
2021-07-16 22:28:44 +10:00
parent 99e99da340
commit e1a3ad388c
3 changed files with 35 additions and 17 deletions

View File

@@ -450,6 +450,8 @@ def RunJob(job):
JobProcessAI(job)
elif job.name == "run_ai_on":
JobRunAIOn(job)
elif job.name == "rotate_image":
JobRotateImage(job)
else:
print("ERROR: Requested to process unknown job type: {}".format(job.name))
# okay, we finished a job, so check for any jobs that are dependant on this and run them...
@@ -973,7 +975,6 @@ def AddToJobImageCount(job, entry ):
job.num_files += 1
return
def JobRunAIOn(job):
AddLogForJob(job, f"INFO: Starting looking For faces in files job...")
which_person=[jex.value for jex in job.extra if jex.name == "person"][0]
@@ -1021,7 +1022,31 @@ def JobRunAIOn(job):
AddLogForJob( job, f'Not processing Entry: {entry.name} - not an image' )
FinishJob(job, "Finished Processesing AI")
return
def JobRotateImage(job):
AddLogForJob(job, f"INFO: Starting rotation/flip of image file...")
id=[jex.value for jex in job.extra if jex.name == "id"][0]
amt=[jex.value for jex in job.extra if jex.name == "amt"][0]
e=session.query(Entry).join(File).filter(Entry.id==id).first()
im = Image.open( e.FullPathOnFS() )
print(amt)
if amt == "fliph":
AddLogForJob(job, f"INFO: Flipping {e.FullPathOnFS()} horizontally" )
out = im.transpose(Image.FLIP_LEFT_RIGHT)
elif amt == "flipv":
AddLogForJob(job, f"INFO: Flipping {e.FullPathOnFS()} vertically" )
out = im.transpose(Image.FLIP_TOP_BOTTOM)
else:
AddLogForJob(job, f"INFO: Rotating {e.FullPathOnFS()} by {amt} degrees" )
out = im.rotate(int(amt), expand=True)
out.save( e.FullPathOnFS() )
e.file_details.thumbnail = GenThumb( e.FullPathOnFS() )
session.add(e)
FinishJob(job, "Finished Processesing image rotation/flip")
return
def GenHashAndThumb(job, e):
# commit every 100 files to see progress being made but not hammer the database
if job.current_file_num % 100 == 0:
@@ -1302,13 +1327,10 @@ def RemoveDups(job):
def JobMoveFiles(job):
AddLogForJob(job, f"INFO: Starting Move Files job...")
AddLogForJob(job, f"INFO: NOT PROCESSING THIS - TESTING...")
prefix=[jex.value for jex in job.extra if jex.name == "prefix"][0]
suffix=[jex.value for jex in job.extra if jex.name == "suffix"][0]
storage_rp=[jex.value for jex in job.extra if jex.name == "storage_rp"][0]
print( f"storage_rp={storage_rp}" )
dst_storage_path = session.query(Path).filter(Path.path_prefix=='static/Storage/'+ storage_rp).first()
print( f"dsp={dst_storage_path}" )
for jex in job.extra:
if 'eid-' in jex.name:
move_me=session.query(Entry).join(File).filter(Entry.id==jex.value).first()