No project description provided
Project description
INTRODUCTION
"pil_plus" is a Python package that makes it easier to work with images. It provides a collection of functions that build upon the Python Imaging Library (PIL) and OpenCV, adding additional features and functionality.
Some of the features offered by "pil_plus" include:
- Image resizing: Functions for quickly and easily resizing images to different dimensions.
- Image rotation: Functions for rotating images by any angle.
- Image filtering: Functions for applying various image filters, such as blur, sharpen, and edge detection.
- Writing Text on Images
- Removing background of Images
- Replacing a specific color in the image with another
Overall, "pil_plus" aims to provide a simple and intuitive interface for working with images in Python, making it easy to perform common image manipulation tasks.
Installation
pil_plus can be installed using pip with the following command:
pip install pil-plus
Usage
using pil_plus is as simple as the following:
- Importing the package
- Opening an image
- Getting size of the image
- Resizing and rotating
- Image filtering
- Writing text on image
- Removing background of the image
- Replacing one color with another
- Other common functions
Importing the package
from pil_plus import PilPlus
Opening an image
# using path of the image
image = PilPlus("test.jpg")
# converting numpy array to PilPlus object
image = PilPlus(some_numpy_image_array)
# converting Pil Image to PilPlus object
image = PilPlus(some_pil_image_variable)
# converting base64 string to PilPlus object
image = PilPlus(some_base64_string)
Getting size of the image
# Getting image width
width = image.get_width()
# Getting image height
height = image.get_height()
# Getting image size tuple
size = image.get_size()
Resizing and rotating
Resizing:
# changing width and keeping aspect ratio
image.resize(new_width=1000)
# changing height and keeping aspect ratio
image.resize(new_height=1000)
# changing both width and height
image.resize(new_width=600, new_height=800)
Rotating:
# rotating -45 degrees
image.rotate(-45)
Image filtering
# applying Guassian Blur
image.apply_gaussian_blur()
# sharpening the image
image.sharpen()
# applying background
image.apply_background((255,255,255)) # changes background from transparent (see Removing background of the image) to black
# getting canny edges and showing the returned image
edges = image.get_canny_edges()
edges.show()
Writing Text on image
image.draw_text("The is sample text", text_color=(0, 0, 0), coordinates=(0, 0))
Removing Background of the image
image.remove_background()
Replacing one color with another
# replace black with white
image.replace_color((0,0,0), (255,255,255))
Other common functions
# showing the image
image.show()
# saving the image
image.save() # save as outputs\output.png (incrementing 1 in the file name if it exists)
image.save('some_dir/name.extension') # save in some other path
# returning base64 string
image.get_base64()
# get PIL Image object
image.get_image()
# getting numpy array
image.get_numpy_array()
# Conversion between different color models and conventions
image.rgb_to_bgr()
image.bgr_to_rgb()
image.convert_to_grayscale()
image.convert_to_rgb()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pil_plus-0.2.tar.gz
.
File metadata
- Download URL: pil_plus-0.2.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ea69d0b2e4bfbd81b9cf7ed5617112f71bf0e95d42ce860b8619d28d140e345 |
|
MD5 | 53cfd2d3210fcd4e1cd86267751747aa |
|
BLAKE2b-256 | 5632c456aa9d92d2027f47a0dc7d2c8cc90b3fbed5a3f4afb8664d506598f9fb |
File details
Details for the file pil_plus-0.2-py3-none-any.whl
.
File metadata
- Download URL: pil_plus-0.2-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4dfc29983816afeb11b9785be1781c753bebf66955e85df07171a964b289c931 |
|
MD5 | 9d92970dfa02e3b6a1c2ad6e1dc0df39 |
|
BLAKE2b-256 | 7910bf19aa779453e083b9f551252837d0a84beed8759054cc14ae39aaa69b79 |