Convert into server application.
This commit is contained in:
parent
3016a09b95
commit
6b69da393c
2 changed files with 20 additions and 8 deletions
18
handler.py
18
handler.py
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import importlib
|
import importlib
|
||||||
|
import argparse
|
||||||
|
|
||||||
regs = {
|
regs = {
|
||||||
"\d/\d/\d_\d\.jpg": "krpanosteal",
|
"\d/\d/\d_\d\.jpg": "krpanosteal",
|
||||||
|
@ -25,7 +26,16 @@ def parse_url(url):
|
||||||
return importlib.import_module(selected).process_url
|
return importlib.import_module(selected).process_url
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
url = input("Please input the URL of an image. ")
|
parser = argparse.ArgumentParser()
|
||||||
handler = parse_url(url)
|
parser.add_argument('url', help='URL to process')
|
||||||
image = handler(url)
|
parser.add_argument('--title', help='title to be used for the file name')
|
||||||
image.save("out.png")
|
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")
|
||||||
|
|
|
@ -336,7 +336,7 @@ def krpano_make_tiles(url):
|
||||||
raise ValueError("%s does not seem to be a valid krpano URL." % 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
|
Takes the URL of any image in a krpano panorama and returns a finished
|
||||||
stitched image.
|
stitched image.
|
||||||
|
@ -346,9 +346,11 @@ def krpano_to_equirectangular(url, blender=True):
|
||||||
'''
|
'''
|
||||||
|
|
||||||
stitched = krpano_make_tiles(url)
|
stitched = krpano_make_tiles(url)
|
||||||
function = tiles_to_equirectangular_blender if blender \
|
function = tiles_to_equirectangular_blender
|
||||||
else tiles_to_equirectangular
|
|
||||||
return function(*stitched)
|
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
|
process_url = krpano_to_equirectangular
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue