Convert into server application.

This commit is contained in:
Kumi 2018-10-17 19:25:29 +02:00
parent 3016a09b95
commit 6b69da393c
2 changed files with 20 additions and 8 deletions

View file

@ -2,6 +2,7 @@
import re
import importlib
import argparse
regs = {
"\d/\d/\d_\d\.jpg": "krpanosteal",
@ -25,7 +26,16 @@ def parse_url(url):
return importlib.import_module(selected).process_url
if __name__ == "__main__":
url = input("Please input the URL of an image. ")
handler = parse_url(url)
image = handler(url)
image.save("out.png")
parser = argparse.ArgumentParser()
parser.add_argument('url', help='URL to process')
parser.add_argument('--title', help='title to be used for the file name')
parser.add_argument("--rotation", nargs=3, type=int, help="rotation on x/y/z axes", metavar=("x","y","z"))
parser.add_argument("--resolution", type=int, nargs=2, metavar=("w","h"))
parser.add_argument("--output")
args = parser.parse_args()
handler = parse_url(args.url)
image = handler(args.url, args.rotation or [0,0,0], args.resolution or [3840, 1920])
image.save(args.output + "/" + args.title + ".png")

View file

@ -336,7 +336,7 @@ def krpano_make_tiles(url):
raise ValueError("%s does not seem to be a valid krpano URL." % url)
def krpano_to_equirectangular(url, blender=True):
def krpano_to_equirectangular(url, rotation=[0,0,0], resolution=[0,0]):
'''
Takes the URL of any image in a krpano panorama and returns a finished
stitched image.
@ -346,9 +346,11 @@ def krpano_to_equirectangular(url, blender=True):
'''
stitched = krpano_make_tiles(url)
function = tiles_to_equirectangular_blender if blender \
else tiles_to_equirectangular
return function(*stitched)
function = tiles_to_equirectangular_blender
rx, ry, rz = rotation
width, height = resolution
return function(*stitched, rx=rx, ry=ry, rz=rz, width=width, height=height)
process_url = krpano_to_equirectangular