Skip to main content

cImage - A simple image processing library for Python

Installation

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).

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.

Usage

This image library is not going to give you fancy high performance operations on images. It allows you to read in an image and manipulate its pixels. Then you can save the new image to a file, or you can display the image in a window. Thats really about it, but its really all you want to do if you are teaching an introductory computer science course.

Image Types Supported

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

  • jpeg

  • gif

  • tiff

  • png

  • etc.

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

Example

import image

win = image.ImageWin(480, 640, "Image Processing")
original_image = image.FileImage('lcastle.gif')

width = original_image.get_width()
height = original_image.get_height()
print(width, height)

original_image.draw(win)
my_image = original_image.copy()

for row in range(height):
    for col in range(width):
         v = my_image.get_pixel(col,row)
         v.red = 255 - v.red
         v.green = 255 - v.green
         v.blue = 255 - v.blue
         my_image.set_pixel(col,row,v)

my_image.draw(win)
print(win.get_mouse())
my_image.save('lcastle-inverted.gif')
print(my_image.to_list())
win.exit_on_click()

Metadata

Release files for cs20-image 1.5.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cs20-image 1.5.5
File Size Uploaded
cs20-image-1.5.5.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cs20-image 1.5.5
File Interpreter ABI Platform
cs20_image-1.5.5-py3-none-any.whl Python 3 none any Details

Total release size: 17.2 kB

Release files / cs20-image-1.5.5.tar.gz

Download URL cs20-image-1.5.5.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6e981c6d7bed1f2d28781e356eaeab20ff5e8123e9c246675f02ec454de2dfd0
BLAKE2b-256 checksum
How to use checksums
c46a5267112e7070ba501d0b805fe6d85e109e4c50e41f7e76c9cd7ed3ae87de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / cs20_image-1.5.5-py3-none-any.whl

Download URL cs20_image-1.5.5-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1b116383886b9c9e828b6781b1dd59b6795480cbd8d0dce6a4156d252b5ba1b
BLAKE2b-256 checksum
How to use checksums
462307b7835bdb3ecca8f3c1e8bc76e07940cf69d0e1c410cb3a6813061d2896
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.5.5 This release

2 release files

1.5.4

2 release files

1.5.3

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page