hi onyx
what
Port, what the forget is with your avatarHow make it display different images for white/blueish backgroundAsdf
Black magic.You require fifty-seven pythons and two pieces of paper.
No.
# Import modules.print 'Initializing.'from math import floorimport Image# Initialize images.print 'Loading images.'img1 = Image.open('img1.png')img2 = Image.open('img2.png')maxx = max(img1.size[0], img2.size[0])maxy = max(img1.size[1], img2.size[1])imgf = Image.new('RGBA', (maxx, maxy), (0, 0, 0, 0))ima1 = img1.load()ima2 = img2.load()imaf = imgf.load()# Subsitute color shape.def replace_color(alp, mod): if type(alp) is tuple: if len(alp) == 4: alp = alp[3] else: alp = 255 return ((255, 255, 255, alp), (175, 198, 219, alp))[mod]# Perform operation.print 'Performing operation.'for i in range(maxx * maxy): y = floor(i / maxx) x = i - (y * maxx) try: a = ima1[x, y] except IndexError: a = (0, 0, 0, 0) try: b = ima2[x, y] except IndexError: b = (0, 0, 0, 0) if (x + y) % 2 == 0: # if True: # imaf[x, y] = a imaf[x, y] = replace_color(a, 0) else: # imaf[x, y] = b imaf[x, y] = replace_color(b, 1)# Save output.print 'Exporting.'imgf.save('imgf.png')
only 51 pythonsCode: [Select]# Import modules.print 'Initializing.'from math import floorimport Image# Initialize images.print 'Loading images.'img1 = Image.open('img1.png')img2 = Image.open('img2.png')maxx = max(img1.size[0], img2.size[0])maxy = max(img1.size[1], img2.size[1])imgf = Image.new('RGBA', (maxx, maxy), (0, 0, 0, 0))ima1 = img1.load()ima2 = img2.load()imaf = imgf.load()# Subsitute color shape.def replace_color(alp, mod): if type(alp) is tuple: if len(alp) == 4: alp = alp[3] else: alp = 255 return ((255, 255, 255, alp), (175, 198, 219, alp))[mod]# Perform operation.print 'Performing operation.'for i in range(maxx * maxy): y = floor(i / maxx) x = i - (y * maxx) try: a = ima1[x, y] except IndexError: a = (0, 0, 0, 0) try: b = ima2[x, y] except IndexError: b = (0, 0, 0, 0) if (x + y) % 2 == 0: # if True: # imaf[x, y] = a imaf[x, y] = replace_color(a, 0) else: # imaf[x, y] = b imaf[x, y] = replace_color(b, 1)# Save output.print 'Exporting.'imgf.save('imgf.png')
That has nothing to do with the image
yes it doesplace images named img1.png and img2.png in folder with that scriptrun scriptsuddenly, new image named imgf.png is in folder which displays those two depending on the background
png, obviously.