diff --git a/PixelSorter/README.md b/PixelSorter/README.md new file mode 100644 index 0000000..fc904e0 --- /dev/null +++ b/PixelSorter/README.md @@ -0,0 +1,6 @@ +PixelSorter +======= + +Takes all the pixels in an image and sorts them by value, saving that in a new image file. Didn't turn out quite as I hoped but it's kinda neat. + +It takes quite a long time on large images. \ No newline at end of file diff --git a/PixelSorter/pixelsorter.py b/PixelSorter/pixelsorter.py new file mode 100644 index 0000000..f49835b --- /dev/null +++ b/PixelSorter/pixelsorter.py @@ -0,0 +1,52 @@ +import random +from PIL import Image +import time + +path = "C:/users/owner/desktop/" +name = "image.png" + +image = Image.open(path + name) +width = image.size[0] +height = image.size[1] + +def determinevalue(pixel): + r = pixel[0] + g = pixel[1] + b = pixel[2] + try: + o = pixel[3] + except: + o = 0 + + r = r ** 3 + g = g ** 2 + + + total = r+g+b+o + return total + +pixels = [] +print('Stealing pixels') +for y in range(height): + for x in range(width): + pix = image.getpixel((x, y)) + pixels.append(pix) + +print('Sorting pixels') +pixels.sort(key=determinevalue, reverse=True) + +print('Creating new image') +newimage = image.copy() +newpixels = newimage.load() + +print('Applying new pixels') +pos = 0 +for y in range(height): + for x in range(width): + newpixels[x, y] = pixels[pos] + pos += 1 + #pixels = pixels[1:] + print("%d / %d" % (y, height)) + +print('Saving new file') +newimage.save(path + name.replace('.', '_sorted.'), quality=100) \ No newline at end of file diff --git a/RCONRelay/rconrelay.py b/RCONRelay/rconrelay.py index 47fca3d..ccb54bc 100644 --- a/RCONRelay/rconrelay.py +++ b/RCONRelay/rconrelay.py @@ -15,10 +15,11 @@ class RCONRelay: "obj_sentrygun3": "Sentry lvl 3", "shotgun_pyro": "Shotgun", "shotgun_soldier": "Shotgun", - "shotgun_primary": "Shotgun" + "shotgun_primary": "Shotgun", + "club": "Kukri" } - self.ip = "" + self.ip = "0.0.0.0" self.port = 32768 def start(self):