Skip to content

Commit 248ff13

Browse files
author
Dan Schellenberg
committed
updated readme and setup
1 parent 8747bfc commit 248ff13

File tree

3 files changed

+49
-44
lines changed

3 files changed

+49
-44
lines changed

README.rst

+27-26
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ cImage - A simple image processing library for Python
55
Installation
66
============
77

8-
copy cImage.py to your site-packages directory.
8+
9+
If using Thonny, go to Tools -> Manage Packages, then enter ``cs20-image``. This should install both the image module, and the Pillow module (so you can use any type of image you'd like).
10+
11+
12+
If you are not using Thonny, copy image.py to your site-packages directory, or just keep it in the same folder as the Python scripts that import it.
913

1014

1115
Usage
@@ -16,7 +20,7 @@ This image library is not going to give you fancy high performance operations on
1620
Image Types Supported
1721
---------------------
1822

19-
If you have PIL installed on your system:
23+
If you have PIL installed on your system (if you are using Thonny, this was installed along with the image module):
2024

2125
* jpeg
2226
* gif
@@ -26,37 +30,34 @@ If you have PIL installed on your system:
2630

2731
If you do not have PIL installed then you are stuck with GIF images only.
2832

29-
If you are using Python 2.6/2.7 I recommend you install Pillow its a simple fork
30-
of PIL that you can install with easy_install or pip.
31-
32-
If you are using Python 3 You can get a working version of PIL
33-
Here: https://pypi.python.org/pypi/Pillow/2.0.0
34-
35-
Note that if you scroll down to the bottom you will find binary installations for Windows. Linux and Mac users can follow the instructions on the page.
36-
3733

3834
Example
3935
-------
4036

4137
::
4238

43-
from cImage import *
44-
myimagewindow = ImageWin("Image Processing",600,300)
45-
oldimage = FileImage("lutherbell.jpg")
46-
oldimage.setPosition(0,0)
47-
oldimage.draw(myimagewindow)
39+
import image
4840

49-
width = oldimage.getWidth()
50-
height = oldimage.getHeight()
51-
newim = EmptyImage(width,height)
41+
win = image.ImageWin(480, 640, "Image Processing")
42+
original_image = image.FileImage('lcastle.gif')
5243

53-
for row in range(height):
54-
for col in range(width):
55-
oldpixel = oldimage.getPixel(col,row)
56-
ave=(oldpixel.getRed()+oldpixel.getGreen()+oldpixel.getBlue())/3
57-
newim.setPixel(col,row,Pixel(ave,ave,ave))
44+
width = original_image.get_width()
45+
height = original_image.get_height()
46+
print(width, height)
5847

59-
newim.setPosition(width+1,0)
60-
newim.draw(myimagewindow)
48+
original_image.draw(win)
49+
my_image = original_image.copy()
6150

62-
myimagewindow.exitOnClick()
51+
for row in range(height):
52+
for col in range(width):
53+
v = my_image.get_pixel(col,row)
54+
v.red = 255 - v.red
55+
v.green = 255 - v.green
56+
v.blue = 255 - v.blue
57+
my_image.set_pixel(col,row,v)
58+
59+
my_image.draw(win)
60+
print(win.get_mouse())
61+
my_image.save('lcastle-inverted.gif')
62+
print(my_image.to_list())
63+
win.exit_on_click()

cImage.py image.py

+17-13
Original file line numberDiff line numberDiff line change
@@ -521,23 +521,27 @@ def __init__(self,thelist):
521521

522522
# Example program Read in an image and calulate the negative.
523523
if __name__ == '__main__':
524-
win = ImageWin(480,640)
525-
oImage = FileImage('lcastle.gif')
526-
print(oImage.get_width(), oImage.get_height())
527-
oImage.draw(win)
528-
myImage = oImage.copy()
529-
530-
for row in range(myImage.get_height()):
531-
for col in range(myImage.get_width()):
532-
v = myImage.get_pixel(col,row)
524+
win = ImageWin(480, 640, "Image Processing")
525+
original_iamge = FileImage('lcastle.gif')
526+
527+
width = original_iamge.get_width()
528+
height = original_iamge.get_height()
529+
print(width, height)
530+
531+
original_iamge.draw(win)
532+
my_image = original_iamge.copy()
533+
534+
for row in range(height):
535+
for col in range(width):
536+
v = my_image.get_pixel(col,row)
533537
v.red = 255 - v.red
534538
v.green = 255 - v.green
535539
v.blue = 255 - v.blue
536540
# x = map(lambda x: 255-x, v)
537-
myImage.set_pixel(col,row,v)
541+
my_image.set_pixel(col,row,v)
538542

539-
myImage.draw(win)
543+
my_image.draw(win)
540544
print(win.get_mouse())
541-
myImage.save('lcastle-inverted.gif')
542-
print(myImage.to_list())
545+
my_image.save('lcastle-inverted.gif')
546+
print(my_image.to_list())
543547
win.exit_on_click()

setup.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
# dependencies = [l.strip() for l in fh]
55

66
setup(
7-
name='cImage',
7+
name='image',
88
description='Image manipulation library for media computation education',
9-
version='1.4.2',
10-
py_modules = ['cImage'],
11-
author = 'Brad Miller',
12-
author_email = 'bonelake@mac.com',
9+
version='1.5.1',
10+
py_modules = ['image'],
11+
author = 'Brad Miller and Dan Schellenberg',
12+
author_email = 'schellenberg@gmail.com',
1313
install_requires= ['Pillow>=2.9.0'],
1414
include_package_data = False,
1515
license='GPL',

0 commit comments

Comments
 (0)