diff --git a/TODO b/TODO index 20feac4..a93b3de 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,5 @@ ## GENERAL - * file browser: - - maybe back feature/button? - - * allow rotate of image (permanently on FS, so its right everywhere) - * face locations: START FORM SCRATCH so all images have face_locn data right now GenThumb is in shared, and does width, height as well --> in person.py BUT need this for pa_job_manager diff --git a/pa_job_manager.py b/pa_job_manager.py index 9c68b11..f7fe887 100644 --- a/pa_job_manager.py +++ b/pa_job_manager.py @@ -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() diff --git a/templates/files.html b/templates/files.html index 78e1ef6..e8b3ada 100644 --- a/templates/files.html +++ b/templates/files.html @@ -18,7 +18,7 @@ {% if search_term is defined %} {% endif %} -