# Path: opc/utils/prof.py
# def timefunc(f, reference=False):
#     global records
# 
#     records[f.__name__] = Record(f.__name__, reference)
# 
#     @wraps(f)
#     def f_timer(*args, **kwargs):
#         global active
# 
#         if not active:
#             return f(*args, **kwargs)
# 
#         start = time.time()
#         result = f(*args, **kwargs)
#         end = time.time()
# 
#         records[f.__name__].addTime(end-start)
# 
#         return result
# 
#     return f_timer


import numpy as np
from PIL import Image as PI
from io import BytesIO
from .utils.prof import timefunc


class Image(object):

    def __init__(self, filename=None, bytestream=None):
        if filename is not None:
            image = PI.open(filename).rotate(-90, PI.BICUBIC).convert('RGB')
            self.image = image

        if bytestream is not None:
            self.image = PI.open(BytesIO(bytestream))

        self.width, self.height = self.image.size


# Path: opc/utils/prof.py
# def timefunc(f, reference=False):
#     global records
# 
#     records[f.__name__] = Record(f.__name__, reference)
# 
#     @wraps(f)
#     def f_timer(*args, **kwargs):
#         global active
# 
#         if not active:
#             return f(*args, **kwargs)
# 
#         start = time.time()
#         result = f(*args, **kwargs)
#         end = time.time()
# 
#         records[f.__name__].addTime(end-start)
# 
#         return result
# 
#     return f_timer


# Path: opc/image.py
import numpy as np
from PIL import Image as PI
from io import BytesIO
from .utils.prof import timefunc



class Image(object):

    def __init__(self, filename=None, bytestream=None):
        if filename is not None:
            image = PI.open(filename).rotate(-90, PI.BICUBIC).convert('RGB')
            self.image = image

        if bytestream is not None:
            self.image = PI.open(BytesIO(bytestream))

        self.width, self.height = self.image.size


    @timefunc