diff --git a/shared.py b/shared.py index e7335e3..36dcf59 100644 --- a/shared.py +++ b/shared.py @@ -33,13 +33,16 @@ if hostname == "lappy": PA_JOB_MANAGER_HOST="localhost" DB_URL = 'postgresql+psycopg2://pa:for_now_pa@localhost:5432/pa' # if we dont set the env or we are explicitly DEV, run web server on localhost & db on mara (port 65432) + PA_EXIF_ROTATER = './utils/pa_exifautotran' elif 'FLASK_ENV' not in os.environ or os.environ['FLASK_ENV'] == "development": PA_JOB_MANAGER_HOST="localhost" DB_URL = 'postgresql+psycopg2://pa:for_now_pa@mara.ddp.net:65432/pa' # if we explicitly are on PROD, run web server on localhost (pa_web container) & db on mara (port 5432 on padb container)- only accessed via internal docker ports) + PA_EXIF_ROTATER = './utils/pa_exifautotran' elif os.environ['FLASK_ENV'] == "production": PA_JOB_MANAGER_HOST="localhost" DB_URL = 'postgresql+psycopg2://pa:for_now_pa@padb/pa' + PA_EXIF_ROTATER = '/code/utils/pa_exifautotran' else: print( "ERROR: I do not know which environment (development, etc.) and which DB (on which host to use)" ) exit( -1 ) @@ -119,7 +122,7 @@ def GenThumb(fname,auto_rotate): try: if auto_rotate: # run cmdline util to re-orient jpeg (only changes if needed, and does it losslessly) - p = subprocess.run(["/usr/bin/exifautotran",fname] ) + p = subprocess.run([PA_EXIF_ROTATER,fname] ) im=Image.open(fname) # if we don't autorotate/touch the original, we still want the thumbnail oriented the right way else: diff --git a/utils/pa_exifautotran b/utils/pa_exifautotran new file mode 100755 index 0000000..30f2b5b --- /dev/null +++ b/utils/pa_exifautotran @@ -0,0 +1,40 @@ +#!/bin/sh +# pa_exifautotran [list of files] +# +# Transforms JPEG files so that Exif Orientation becomes 1 +# +# blatant copy of exitautotran shell script with: +# Minor change made to ignore failure of jpegtran (it was failing +# b/c Samsung images are incomplete, but the rotation works) +for i +do + case $i in + -v|--version) echo "$0 (pa variant)"; exit 0;; + -h|--help) + cat <&2 + jpegtran -copy all $transform "$i" > tempfile + rm "$i" + mv tempfile "$i" + jpegexiforient -1 "$i" + fi +done