@JimSkon/

ImageFun

Python

No description

fork
loading
Files
  • main.py
  • KenyonLogo.png
  • PixelOnPillow.jpg
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#Image Fun
#https://pillow.readthedocs.io/en/5.2.x/handbook/concepts.html#concept-modes
from PIL import Image
#im = Image.open("KenyonLogo.png")
im = Image.open("PixelOnPillow.jpg")

width, height = im.size
print("Original Size:",width,",",height)
#reduce the size of the photo for easier processing
im=im.resize((width//10,height//10))

#Get the new dimensions
width, height = im.size
print("New Size:",width,",",height)

# Convert to RBG
rgb_im = im.convert('RGB')

#Go through the entire set of pixels, changing them
for i in range(width):
  for j in range(height):
      p = rgb_im.getpixel((i, j))
      #print("(",p[0],",",p[1],",",p[2],")",end=" ",sep="")
      #invert each color value
      p1=(256-p[0],256-p[1],256-p[2])
      #Swap color channels around
      #p1=(p[2],p[1],p[0])
      rgb_im.putpixel((i,j),p1)
  #print()


#im=im.rotate(180).resize((200,100))
rgb_im.save('ModifiedImage.jpg',"JPEG")