Browse Source

added new zipscale variant which uses composition instead of inhiterance

master
T. Meissner 10 years ago
parent
commit
4e387a3dc3
1 changed files with 19 additions and 0 deletions
  1. +19
    -0
      python_3_oop/chapter05/zipscale_comp.py

+ 19
- 0
python_3_oop/chapter05/zipscale_comp.py View File

@ -0,0 +1,19 @@
from zipprocessor import ZipProcessorComp
import sys
import os
from pygame import image
from pygame.transform import scale
class ZipScale():
def process(self, zipprocessor):
"""Scale each image in the directory to 640x480"""
for filename in os.listdir(zipprocessor.temp_directory):
im = image.load(zipprocessor._full_filename(filename))
scaled = scale(im, (640, 480))
image.save(scaled, zipprocessor._full_filename(filename))
if __name__ == "__main__":
ZipProcessorComp(sys.argv[1], ZipScale()).process_zip()

Loading…
Cancel
Save