remove last remnants of rotate instead of transform, updated rot* svgs to have arrow point in direction of actual rotation, AND, fixed bug where when we rotate an image that has already had an exif_transform on it, then we have to do that and then the requested rotation - fixes why sometimes we rotate say 180 when we intended a 90 rotate. Also, when we transform, recalc md5 as file has changed
This commit is contained in:
@@ -626,8 +626,8 @@ def RunJob(job):
|
||||
JobRestoreFiles(job)
|
||||
elif job.name == "run_ai_on":
|
||||
JobRunAIOn(job)
|
||||
elif job.name == "rotate_image":
|
||||
JobRotateImage(job)
|
||||
elif job.name == "transform_image":
|
||||
JobTransformImage(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...
|
||||
@@ -1281,15 +1281,16 @@ def JobRunAIOn(job):
|
||||
return
|
||||
|
||||
####################################################################################################################################
|
||||
# JobRotateImage(): rotate an image by the amount requested (can also flip horizontal or vertical)
|
||||
# JobTransformImage(): transform an image by the amount requested (can also flip horizontal or vertical)
|
||||
# TODO: should be JobTransformImage() ;)
|
||||
####################################################################################################################################
|
||||
def JobRotateImage(job):
|
||||
def JobTransformImage(job):
|
||||
JobProgressState( job, "In Progress" )
|
||||
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()
|
||||
print( f"JobTransformImage: job={job.id}, id={id}, amt={amt}" )
|
||||
im = Image.open( e.FullPathOnFS() )
|
||||
|
||||
if amt == "fliph":
|
||||
@@ -1300,9 +1301,14 @@ def JobRotateImage(job):
|
||||
out = im.transpose(Image.FLIP_TOP_BOTTOM)
|
||||
else:
|
||||
AddLogForJob(job, f"INFO: Rotating {e.FullPathOnFS()} by {amt} degrees" )
|
||||
if im.format == 'JPEG':
|
||||
im=ImageOps.exif_transpose(im)
|
||||
out = im.rotate(int(amt), expand=True)
|
||||
out.save( e.FullPathOnFS() )
|
||||
print( f"JobTransformImage DONE transform: job={job.id}, id={id}, amt={amt}" )
|
||||
e.file_details.thumbnail, _ , _ = GenThumb( e.FullPathOnFS() )
|
||||
e.file_details.hash = md5( job, e.FullPathOnFS() )
|
||||
print( f"JobTransformImage DONE thumb: job={job.id}, id={id}, amt={amt}" )
|
||||
session.add(e)
|
||||
FinishJob(job, "Finished Processesing image rotation/flip")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user