diff --git a/example.png b/example.png index 435a3b3..ab5ed78 100644 Binary files a/example.png and b/example.png differ diff --git a/im_convert.py b/im_convert.py index 0e9fdbd..90bcbbb 100644 --- a/im_convert.py +++ b/im_convert.py @@ -1,5 +1,30 @@ from PIL import Image +# [[0,0, rgb1],... [1,1, rgb2]] -> [[1,1, rgb1],...[0,0, rgb2]] +def flip(cords): + fliped = [] + flips = len(cords)//2 + + # El from start and el from end + fl0 = 0 ; fl1 = len(cords)-1 + + for i in range(flips): + # Copy element and change cords to cords of end element + new_st = list(cords[fl0]) + new_st[0] = cords[fl1][0] + new_st[1] = cords[fl1][1] + fliped.append(new_st) + + # Copy and change cords to cords of start element + new_end = list(cords[fl1]) + new_end[0] = cords[fl0][0] + new_end[1] = cords[fl0][1] + fliped.append(new_end) + + fl0 += 1 ; fl1 -= 1 + + return fliped + # convert("example.png") // png/jpg/gif def convert(filename, move = [0,0]): im = Image.open(filename).convert('RGB') @@ -12,6 +37,14 @@ def convert(filename, move = [0,0]): for y in range(h): # [x,y, [r, g, b]] rgb = pxls[x,y] - ll.append( [x + move[0], y + move[1], rgb[0], rgb[1], rgb[2] ] ) + ll.append( [x,y, rgb[0], rgb[1], rgb[2] ] ) + + # Fix flip + fliped = flip(ll) + + # Move [x,y] + move + moved = [] + for i in fliped: + moved.append([i[0] + move[0], i[1] + move[1], i[2],i[3],i[4]]) - return ll + return moved