use jpegtran to do lossless 90 rotations
This commit is contained in:
@@ -23,7 +23,7 @@ from sqlalchemy.orm import sessionmaker
|
||||
from sqlalchemy.orm import scoped_session
|
||||
|
||||
### LOCAL FILE IMPORTS ###
|
||||
from shared import DB_URL, PA_JOB_MANAGER_HOST, PA_JOB_MANAGER_PORT, THUMBSIZE, SymlinkName, GenThumb, SECS_IN_A_DAY
|
||||
from shared import DB_URL, PA_JOB_MANAGER_HOST, PA_JOB_MANAGER_PORT, THUMBSIZE, SymlinkName, GenThumb, SECS_IN_A_DAY, PA_EXIF_ROTATER
|
||||
from datetime import datetime, timedelta, date
|
||||
|
||||
### PYTHON LIB IMPORTS ###
|
||||
@@ -45,6 +45,7 @@ import face_recognition
|
||||
import re
|
||||
import sys
|
||||
import ffmpeg
|
||||
import subprocess
|
||||
|
||||
|
||||
# global debug setting
|
||||
@@ -1901,21 +1902,20 @@ def JobTransformImage(job):
|
||||
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":
|
||||
AddLogForJob(job, f"INFO: Flipping {e.FullPathOnFS()} horizontally" )
|
||||
im = Image.open( e.FullPathOnFS() )
|
||||
out = im.transpose(Image.FLIP_LEFT_RIGHT)
|
||||
out.save( e.FullPathOnFS() )
|
||||
elif amt == "flipv":
|
||||
AddLogForJob(job, f"INFO: Flipping {e.FullPathOnFS()} vertically" )
|
||||
im = Image.open( e.FullPathOnFS() )
|
||||
out = im.transpose(Image.FLIP_TOP_BOTTOM)
|
||||
out.save( e.FullPathOnFS() )
|
||||
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}" )
|
||||
p = subprocess.run([PA_EXIF_ROTATER, e.FullPathOnFS(), amt ] )
|
||||
settings = session.query(Settings).first()
|
||||
e.file_details.thumbnail, _ , _ = GenThumb( e.FullPathOnFS(), settings.auto_rotate )
|
||||
e.file_details.hash = md5( job, e )
|
||||
|
||||
Reference in New Issue
Block a user