The pyimager package contains functions that aid in image manipulation and processing.
This package was developed as a project for DSCI-524.
Name | GitHub |
---|---|
Keanna Knebel | Keanna-K |
Mohammed Salama | dataubc |
Zhengyang (Zoe) Pan | zoepan00 |
Haoyu (Clara) Su | clsu22 |
To contribute to this project, you must adhere to the terms outlined in our Code of Conduct.
Want to edit an image in the shell instead of GUI applications? pyimager
is a python package that provides a quick and easy way to do some simple image processing and graphic editing. Based on the main needs of graphic editing, the package integrates four functionalities. The functionalities include: reducing the size of an image, cropping an image into a circle, reducing the number of colours in an image, and applying cool filter effects. By inputing the path of the image, users can run any of these functions with one line of code to get the desired image.
In your console, type:
pip install -i https://test.pypi.org/simple/ pyimager
- Python 3.7 or greater
- numpy = "^1.18.1"
- Pillow = "^7.0.0"
- scipy = "^1.4.1"
- matplotlib = "^3.2.0"
circropper
: This function crops the input image into a circle. This can be useful when you want to make icons from images.redusize
: This function reduces the dimension of a given image by removing first columns and/or rows of the image according to the desired new width/height, as in the example below.imgfilter
: This function applies a filter to a given image, altering the visual aesthetic. This includes options to blur and sharpen the image with varying degrees of strength. This filter effect is achieved through the application of a matrix convolution with the filter kernel and original image.reducolor
: This function reduces the image colors to get the cartoonized color effect. This can be either selected two colors images or eight colors images.
We will use mandrill.jpg
saved in the images
folder of this repository for the examples.
from pyimager import pyimager
pyimager.circropper(input_path='images/mandrill.jpg', margin=0, output_path='images/mandrill_circropper.png')
from pyimager import pyimager
pyimager.imgfilter(input_path="images/mandrill.jpg", filter_type="blur", strength=0.4, output_path="images/mandrill_blur.png")
from pyimager import pyimager
pyimager.imgfilter(input_path="images/mandrill.jpg", filter_type="sharpen", strength=0.2, output_path="images/mandrill_sharpen.png")
from pyimager import pyimager
#style 0, reduce the image color to white and black and save the new image mandrill_reducolor0.jpg in the images folder
pyimager.reducolor(input_path='images/mandrill.jpg', style=['black', 'white'], output_path='images/mandrill_reducolor0.jpg')
#style 1, reduce the image color to 8 colors and save the new image mandrill_reducolor1.jpg in the images folder
pyimager.reducolor(input_path='images/mandrill.jpg', style=['eight'], output_path='images/mandrill_reducolor1.jpg')
from pyimager import pyimager
# reduce the size from width 298 and height 298 to width 201 height 201
pyimager.redusize("images/mandrill.jpg", "images/reduced_mandrill.jpg", 201, 200)
The official documentation is hosted on Read the Docs: https://pyimager.readthedocs.io/en/latest/
We have a package with the same functionalities in R : rimager
. See here
There are existing packages to process images. For example scikit-image
here, PIL
here are popular packages that can be used to resize, cut images and apply filters. The goal of this package is either to utilize packages like matplotlib
, PIL
to improve the pre-existing functions or to re-implement code manually with numpy
. Also it automates the image editing process, producing the altered image by one line of code.
This package was created with Cookiecutter and the UBC-MDS/cookiecutter-ubc-mds project template, modified from the pyOpenSci/cookiecutter-pyopensci project template and the audreyr/cookiecutter-pypackage.