created own version of exifautotran (placed into utils), and call it from ./ in non PROD and explciti /code in PROD - it deals with the Samsung created images with invalid SOS which dont autorotate
This commit is contained in:
@@ -33,13 +33,16 @@ if hostname == "lappy":
|
|||||||
PA_JOB_MANAGER_HOST="localhost"
|
PA_JOB_MANAGER_HOST="localhost"
|
||||||
DB_URL = 'postgresql+psycopg2://pa:for_now_pa@localhost:5432/pa'
|
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)
|
# 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":
|
elif 'FLASK_ENV' not in os.environ or os.environ['FLASK_ENV'] == "development":
|
||||||
PA_JOB_MANAGER_HOST="localhost"
|
PA_JOB_MANAGER_HOST="localhost"
|
||||||
DB_URL = 'postgresql+psycopg2://pa:for_now_pa@mara.ddp.net:65432/pa'
|
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)
|
# 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":
|
elif os.environ['FLASK_ENV'] == "production":
|
||||||
PA_JOB_MANAGER_HOST="localhost"
|
PA_JOB_MANAGER_HOST="localhost"
|
||||||
DB_URL = 'postgresql+psycopg2://pa:for_now_pa@padb/pa'
|
DB_URL = 'postgresql+psycopg2://pa:for_now_pa@padb/pa'
|
||||||
|
PA_EXIF_ROTATER = '/code/utils/pa_exifautotran'
|
||||||
else:
|
else:
|
||||||
print( "ERROR: I do not know which environment (development, etc.) and which DB (on which host to use)" )
|
print( "ERROR: I do not know which environment (development, etc.) and which DB (on which host to use)" )
|
||||||
exit( -1 )
|
exit( -1 )
|
||||||
@@ -119,7 +122,7 @@ def GenThumb(fname,auto_rotate):
|
|||||||
try:
|
try:
|
||||||
if auto_rotate:
|
if auto_rotate:
|
||||||
# run cmdline util to re-orient jpeg (only changes if needed, and does it losslessly)
|
# 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)
|
im=Image.open(fname)
|
||||||
# if we don't autorotate/touch the original, we still want the thumbnail oriented the right way
|
# if we don't autorotate/touch the original, we still want the thumbnail oriented the right way
|
||||||
else:
|
else:
|
||||||
|
|||||||
40
utils/pa_exifautotran
Executable file
40
utils/pa_exifautotran
Executable file
@@ -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 <<EOF
|
||||||
|
$0 [list of files]
|
||||||
|
Transforms JPEG files so that Exif Orientation becomes 1
|
||||||
|
EOF
|
||||||
|
exit 0;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case $(exiftool -t -s -s -s -n -IFD0:Orientation -IFD1:Orientation "$i") in
|
||||||
|
1) transform="";;
|
||||||
|
2) transform="-flip horizontal";;
|
||||||
|
3) transform="-rotate 180";;
|
||||||
|
4) transform="-flip vertical";;
|
||||||
|
5) transform="-transpose";;
|
||||||
|
6) transform="-rotate 90";;
|
||||||
|
7) transform="-transverse";;
|
||||||
|
8) transform="-rotate 270";;
|
||||||
|
*) transform="";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if test -n "$transform"; then
|
||||||
|
echo Executing: jpegtran -copy all $transform "$i" >&2
|
||||||
|
jpegtran -copy all $transform "$i" > tempfile
|
||||||
|
rm "$i"
|
||||||
|
mv tempfile "$i"
|
||||||
|
jpegexiforient -1 "$i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
Reference in New Issue
Block a user