forked from oracle-samples/oracle-functions-samples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunc.py
28 lines (24 loc) · 693 Bytes
/
func.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#
# imagedims-python version 1.0.
#
# Copyright (c) 2020 Oracle, Inc.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
#
import io
import json
import tempfile
from fdk import response
from wand.image import Image
def handler(ctx, data: io.BytesIO=None):
resp = {}
with tempfile.TemporaryFile() as tempf:
tempf.write(data.getbuffer())
tempf.seek(0)
with Image(file = tempf) as img:
resp["width"] = img.width
resp["height"] = img.height
return response.Response(
ctx,
response_data=json.dumps(resp),
headers={"Content-Type": "application/json"}
)