# Path: opc/image.py
# 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
#     def translate(self, matrix, scale=0, x=0, y=0):
#         i = self.image.copy()
#         if scale == 0:
#             i = self.image.resize((matrix.height, matrix.width), PI.ANTIALIAS)
#         else:
#             i = self.image.resize((int(self.height/scale),
#                                    int(self.width/scale)), PI.ANTIALIAS)
# 
#         return np.asarray(i.crop((y, x, y+matrix.height, x+matrix.width)))


from ._baseclass import ArtBaseClass
    from thread import start_new_thread, allocate_lock
    from _thread import start_new_thread, allocate_lock
from opc.image import Image
import requests
import logging




def position(matrix, image):
    x = 0
    y = 0

    while y < (image.height-matrix.height):
        while x < image.width-matrix.width:
            yield x, y
            x += 1

        dy = 0
        while dy < matrix.height and y < (image.height-matrix.height):
            yield x, y
            y += 1
            dy += 1

        while x > 0 and y < (image.height-matrix.height):
            yield x, y
            x -= 1

        dy = 0
        while dy < matrix.height and y < (image.height-matrix.height):
            yield x, y
            y += 1
            dy += 1



# Path: opc/image.py
# 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
#     def translate(self, matrix, scale=0, x=0, y=0):
#         i = self.image.copy()
#         if scale == 0:
#             i = self.image.resize((matrix.height, matrix.width), PI.ANTIALIAS)
#         else:
#             i = self.image.resize((int(self.height/scale),
#                                    int(self.width/scale)), PI.ANTIALIAS)
# 
#         return np.asarray(i.crop((y, x, y+matrix.height, x+matrix.width)))


# Path: art/panimage.py
from ._baseclass import ArtBaseClass
    from thread import start_new_thread, allocate_lock
    from _thread import start_new_thread, allocate_lock
from opc.image import Image
import requests
import logging





def position(matrix, image):
    x = 0
    y = 0

    while y < (image.height-matrix.height):
        while x < image.width-matrix.width:
            yield x, y
            x += 1

        dy = 0
        while dy < matrix.height and y < (image.height-matrix.height):
            yield x, y
            y += 1
            dy += 1

        while x > 0 and y < (image.height-matrix.height):
            yield x, y
            x -= 1

        dy = 0
        while dy < matrix.height and y < (image.height-matrix.height):
            yield x, y
            y += 1
            dy += 1



class Art(ArtBaseClass):