[ Prev ]
2021-10-03

-- Sep 29 In-Class Exercise
from PIL import Image, ImageGrab im = ImageGrab.grab(bbox =(0, 0, 1280, 800)) out_im = im.resize((100,100)).convert('L') out_im.show()
Resource Description for tmpt_bhai5i.jpg
<nowiki> from PIL import Image, ImageGrab im = ImageGrab.grab(bbox =(0, 0, 1280, 800)) out_im = im.resize((100,100)).convert('L') out_im.show() </nowiki> ((resource:tmpt_bhai5i.jpg|Resource Description for tmpt_bhai5i.jpg))

-- Sep 29 In-Class Exercise
from PIL import Image, ImageGrab
myImage = ImageGrab.grab()
myImage = ImageGrab.grab((0,0,1440,900))
myImage=myImage.resize((150,150))
myImage.convert('L')
myImage.show()
Resource Description for tmptxezn4_k.jpg
(Edited: 2021-10-03)
from PIL import Image, ImageGrab myImage = ImageGrab.grab() myImage = ImageGrab.grab((0,0,1440,900)) myImage=myImage.resize((150,150)) myImage.convert('L') myImage.show() ((resource:tmptxezn4_k.jpg|Resource Description for tmptxezn4_k.jpg))

-- Sep 29 In-Class Exercise
from PIL import Image, ImageOps import pyscreenshot as ImageGrab
im = ImageGrab.grab() # capture whole screen
im = ImageGrab.grab((10,10,250,250))
gray_im = ImageOps.grayscale(im)
out_im = gray_im.resize((100, 100))
gray_im.show()
Resource Description for Screenshot from 2021-10-03 23-30-43.png
(Edited: 2021-10-03)
from PIL import Image, ImageOps import pyscreenshot as ImageGrab im = ImageGrab.grab() # capture whole screen im = ImageGrab.grab((10,10,250,250)) gray_im = ImageOps.grayscale(im) out_im = gray_im.resize((100, 100)) gray_im.show() ((resource:Screenshot from 2021-10-03 23-30-43.png|Resource Description for Screenshot from 2021-10-03 23-30-43.png))

-- Sep 29 In-Class Exercise
Code: Resource Description for screenshot_code.jpg
Entire screenshot Resource Description for PIL_screenshot.png
Screenshot of top-left quadrant Resource Description for PIL_screenshot_TLQuadrant.png
After resizing the quadrant to 100x100 grayscale image Resource Description for PIL_screenshot_TLResized.png
(Edited: 2021-10-04)
Code: ((resource:screenshot_code.jpg|Resource Description for screenshot_code.jpg)) '''Entire screenshot''' ((resource:PIL_screenshot.png|Resource Description for PIL_screenshot.png)) '''Screenshot of top-left quadrant''' ((resource:PIL_screenshot_TLQuadrant.png|Resource Description for PIL_screenshot_TLQuadrant.png)) '''After resizing the quadrant to 100x100 grayscale image''' ((resource:PIL_screenshot_TLResized.png|Resource Description for PIL_screenshot_TLResized.png))

-- Sep 29 In-Class Exercise
from PIL import Image, ImageGrab
img = ImageGrab.grab() img = ImageGrab.grab((0,0,img.size[0]/2,img.size[1]/2)) resized_img = img.resize((100,100)) grayscale_img = resized_img.convert('L') grayscale_img.show() grayscale_img.save("100by100Grayscale.jpeg")
Resource Description for 100by100Grayscale.jpeg
from PIL import Image, ImageGrab img = ImageGrab.grab() img = ImageGrab.grab((0,0,img.size[0]/2,img.size[1]/2)) resized_img = img.resize((100,100)) grayscale_img = resized_img.convert('L') grayscale_img.show() grayscale_img.save("100by100Grayscale.jpeg") ((resource:100by100Grayscale.jpeg|Resource Description for 100by100Grayscale.jpeg))

-- Sep 29 In-Class Exercise
from PIL import Image, ImageGrab,ImageOps
im = ImageGrab.grab()
width = im.size[0]/2
height = im.size[1]/2
im = ImageGrab.grab(bbox=(0,0,width,height))
output_im = im.resize((100,100))
final_im = ImageOps.grayscale(output_im)
final_im.save('quadrant.png')
final_im.show()
Resource Description for quadrant.png
(Edited: 2021-10-04)
from PIL import Image, ImageGrab,ImageOps im = ImageGrab.grab() width = im.size[0]/2 height = im.size[1]/2 im = ImageGrab.grab(bbox=(0,0,width,height)) output_im = im.resize((100,100)) final_im = ImageOps.grayscale(output_im) final_im.save('quadrant.png') final_im.show() ((resource:quadrant.png|Resource Description for quadrant.png))
X