forked from expo/troggle
ROTATE image option
This commit is contained in:
@@ -407,7 +407,37 @@ def expofilerename(request, filepath):
|
||||
and it returns control to the original wallet edit page
|
||||
"""
|
||||
def rotate_image():
|
||||
print("ROTATE")
|
||||
wallet = str(Path(filepath).parent).lstrip("surveyscans/")
|
||||
cwd = settings.SCANS_ROOT / wallet
|
||||
print(f"ROTATE \n{cwd=} \n{filename=}")
|
||||
mogrify = settings.MOGRIFY
|
||||
rot = subprocess.run(
|
||||
[mogrify, "-rotate", "90", filename], cwd=cwd, capture_output=True, text=True
|
||||
)
|
||||
msgdata = (
|
||||
rot.stderr
|
||||
+ "\n"
|
||||
+ rot.stdout
|
||||
+ "\nreturn code: "
|
||||
+ str(rot.returncode)
|
||||
)
|
||||
message = f'! - ROTATE - Success: rotated this file {filename}.' + msgdata
|
||||
print(message)
|
||||
if rot.returncode != 0:
|
||||
msgdata = (
|
||||
"Ask a nerd to fix this.\n\n"
|
||||
+ rot.stderr
|
||||
+ "\n\n"
|
||||
+ rot.stdout
|
||||
+ "\n\nreturn code: "
|
||||
+ str(rot.returncode)
|
||||
)
|
||||
message = (
|
||||
f"! - ROTATE - CANNOT blurk for this file {filename}. \n"
|
||||
+ msgdata
|
||||
)
|
||||
print(message)
|
||||
|
||||
return simple_get()
|
||||
|
||||
def simple_get():
|
||||
@@ -427,6 +457,7 @@ def expofilerename(request, filepath):
|
||||
)
|
||||
|
||||
if filepath:
|
||||
# using EXPOFILES not SCANS_ROOT in case we want to extend this to other parts of the system
|
||||
actualpath = Path(settings.EXPOFILES) / Path(filepath)
|
||||
else:
|
||||
message = f'\n File to rename not specified "{filepath}"'
|
||||
|
||||
Reference in New Issue
Block a user