Tag Archives: Python
Resizing and recoloring images with Python
import Image # I have the power! theFile = "foo.png" # the file to start with img = Image.open(theFile) # open the image resized = img.resize((75,75)) # resize the image r, g, b, alpha = resized.split() # get … Continue reading
Python MySQL Associative Array
By default, the MySQLdb module to access a MySQL database returns the data as an integer indexed array. Sometimes this is not desirable and an associative array is preferred, such as the mysql_fetch_assoc function in PHP. In addition, we will … Continue reading
Python Print Screen and Save Image in Windows
So you need to do a “Print Screen” and save the image in the clipboard huh? I had that exact need too. Let me save you a few hours of trouble and tell you that the win32clipboard does not yet … Continue reading
Python Abstract Snow Art using PyGame
# # Abstract Random Snow Art # Copyright 2009 Travis Crowder # travis.crowder@spechal.com # Published under the MIT License # import pygame, sys, random from pygame.color import THECOLORS pygame.init() screen = pygame.display.set_mode([640,480]) screen.fill([0,0,0]) for i in range(1, 2500): top = … Continue reading
Python Abstract Box Art using PyGame
# # Abstract Random Box Art # Copyright 2009 Travis Crowder # travis.crowder@spechal.com # Published under the MIT License # import pygame, sys, random from pygame.color import THECOLORS pygame.init() screen = pygame.display.set_mode([640,480]) screen.fill([0,0,0]) for i in range(1, 100): width = … Continue reading
