Skip to main content

A special Python image submodule for beginners.

Project description

A special Python image submodule for beginners.

Description

image_novice is a simple wrapper around the Python Image Library (PIL) for beginners. It allows for easy loading, manipulating, and saving of image files.

NOTE: This module uses the Cartesian coordinate system!

Example

>>> import image_novice as novice         # special submodule for beginners

>>> picture = novice.open('sample.png')   # create a picture object from a file
>>> print picture.format                  # pictures know their format...
'png'
>>> print picture.path                    # ...and where they came from...
'/Users/example/sample.png'
>>> print picture.size                    # ...and their size
(665, 500)
>>> print picture.width                   # 'width' and 'height' also exposed
665
>>> picture.size = (200, 250)             # changing size automatically resizes
>>> for pixel in picture:                 # can iterate over pixels
>>> ... if ((pixel.red > 128) and         # pixels have RGB (values are 0-255)...
>>> ...     (pixel.x < picture.width)):   # ...and know where they are
>>> ...     pixel.red /= 2                # pixel is an alias into the picture
>>> ...
>>> print picture.modified                # pictures know if their pixels are dirty
True
>>> print picture.path                    # picture no longer corresponds to file
None
>>> picture[0:20, 0:20] = (0, 0, 0)       # overwrite lower-left rectangle with black
>>> picture.save('sample-bluegreen.jpg')  # guess file type from suffix
>>> print picture.path                    # picture now corresponds to file
'/Users/example/sample-bluegreen.jpg'
>>> print picture.format                  # ...has a different format
jpeg
>>> print picture.modified                # and is now in sync
False

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

image_novice-0.1.2.tar.gz (16.2 kB view details)

Uploaded Source

File details

Details for the file image_novice-0.1.2.tar.gz.

File metadata

File hashes

Hashes for image_novice-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f86811fed41638c84ab1428e6ece461cdc6ed004dc42da88302bbd7206d5c873
MD5 81af4eded8a68f2e3e43f4dc74478f09
BLAKE2b-256 d7217b5555d77e24bf94d4b04b5c49075164a60a19b7752d5d2ff256b8935e8e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page