Create various icon masks and shading effects with the imageedit library
Project description
ImageEdit
Create various icon masks and shading effects with the imageedit library. Four example files: round.py, makeProjIcons.py, makePWAImages.py and getPWAScreenshots.py. Includes imagetracer.py. imagetracer.py uses JS and is much faster than previous implementations. Takes a few seconds and has no cap.
- Library Files
- Example Files
- Comparison to similar solutions
- How to use out of the box (makePWAImages)
- Example usage and docs for layered images
- Install With PIP
- Language information
- Install Python on Windows
- Install Python on Linux
- How to run
- Download
- Community Files
- Screenshots
Library Files
Generate docs with
pydocmd simple imageedit.effects++ imageedit.imagegrab++ imageedit.imagetracer++ imageedit.io++ imageedit.transform++ > Docs.md
See the Docs for more information.
Example Files
- round.py
- makeProjIcons.py
- makePWAImages.py
- readWriteLayered.py
- getPWAScreenshots.py
Comparison to similar solutions
Similar solutions include but are not limited to:
GUI
Web
https://realfavicongenerator.net/
Advantages of this solution
- Minimal: few dependencies required (python and pillow)
- Quick: when given a regular or mask image it can produce a large number or variants in a relatively short amount of time
- Customisable: write your own scripts to leverage imageEdit (python knowledge required)
- Produce a PWA mask icon out of the box
- SVG tracing lib doesn't require potrace/ pypotrace which can be challenging to set up on Windows
- SVG tracing using imageTracerJs.py (https://github.com/jankovicsandras/imagetracerjs) is pretty good (requires pyppeteer: https://github.com/miyakogi/pyppeteer)
Disadvantages of this solution
- Specific image dimensions needed out of the box: whilst this is something that could be changed, maskable icons are 640x640 and regular icons are 512x512
How to use out of the box (makePWAImages)
-
Put regular 512x512 image or mask 640x640 image under main/input in this example I am using lightfox.png
-
Run
makePWAImages.py
and navigate to main/output/lightfox.png/pwa
Example usage and docs for layered images
Layered images are supported but offsets are very wonky at this stage. Therefore,
when manually adding and inserting layers, use the addLayerRaster
and
insertLayerRaster
functions to add a PIL Image as a layer.
class Layer:
""" A representation of an image layer """
def __init__(self, image, name, offsets, opacity, visible, dimensions):
self.image = image
self.name = name
self.offsets = offsets # Doesn't look to be required
self.opacity = opacity
self.visible = visible
self.dimensions = dimensions
class LayeredImage:
""" A representation of a layered image such as an ora """
def __init__(self, layers, dimensions):
self.layers = layers
self.dimensions = dimensions
def addLayerRaster(self, image, name, offsets=(0, 0)):
""" The recommended way to add a layer """
def insertLayerRaster(self, image, name, index, offsets=(0, 0)):
""" The recommended way to insert a layer """
def getLayer(self, index):
""" Get a layer """
def addLayer(self, layer):
""" Add a layer """
def insertLayer(self, layer, index):
""" Insert a layer at a specific index """
def removeLayer(self, index):
""" Remove a layer at a specific index """
def getFlattenLayers(self, ignoreHidden=True):
""" Return an image for all flattened layers """
def getFlattenTwoLayers(self, background, foreground, ignoreHidden=True):
""" Return an image for two flattened layers """
def flattenTwoLayers(self, background, foreground, ignoreHidden=True):
""" Flatten two layers """
def flattenLayers(self, ignoreHidden=True):
""" Flatten all layers """
To modify a layer you would need to do something like:
# Grab the PIL Image from a layer and do stuff
layer = layeredImage.getLayer(1).image
crop = imageedit.transform.cropCentre(layer, 100, 100)
# Remove the old layer 1 and raster the new layer 1
layeredImage.removeLayer(1)
layeredImage.insertLayerRaster(crop, "Cropped Layer @1", 1, offsets=(50, 0))
Install With PIP
pip install imageedit
Head to https://pypi.org/project/imageedit/ for more info
See python files under main for example usage
Language information
Built for
This program has been written for Python 3 and has been tested with Python version 3.8.0 https://www.python.org/downloads/release/python-380/.
Install Python on Windows
Chocolatey
choco install python
Download
To install Python, go to https://www.python.org/ and download the latest version.
Install Python on Linux
Apt
sudo apt install python3.8
How to run
With VSCode
- Open the .py file in vscode
- Ensure a python 3.8 interpreter is selected (Ctrl+Shift+P > Python:Select Interpreter > Python 3.8)
- Run by pressing Ctrl+F5 (if you are prompted to install any modules, accept)
From the Terminal
./[file].py
Download
Clone
Using The Command Line
- Press the Clone or download button in the top right
- Copy the URL (link)
- Open the command line and change directory to where you wish to clone to
- Type 'git clone' followed by URL in step 2
$ git clone https://github.com/[user-name]/[repository]
More information can be found at https://help.github.com/en/articles/cloning-a-repository
Using GitHub Desktop
- Press the Clone or download button in the top right
- Click open in desktop
- Choose the path for where you want and click Clone
More information can be found at https://help.github.com/en/desktop/contributing-to-projects/cloning-a-repository-from-github-to-github-desktop
Download Zip File
- Download this GitHub repository
- Extract the zip archive
- Copy/ move to the desired location
Community Files
Licence
MIT License Copyright (c) FredHappyface (See the LICENSE for more information.)
Changelog
See the Changelog for more information.
Code of Conduct
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone. Please see the Code of Conduct for more information.
Contributing
Contributions are welcome, please see the Contributing Guidelines for more information.
Security
Thank you for improving the security of the project, please see the Security Policy for more information.
Screenshots
Desktop
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
Hashes for imageedit-2020.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54a5276a23e04d651e155b0599cc1a87c4cc91840b10e76f45bfeb0a47e80dfa |
|
MD5 | 8ba7567224f67167329a2bead5c7ced9 |
|
BLAKE2b-256 | 0f509f2461ee67bfccd8d891191bb5bb4e40ddb9a0bbcd87b2179c7092e8ab84 |