Skip to main content

An open source image processing library that supports blend modes, curve adjustment, and other adjustments that graphic designers or photographers frequently use

Project description

Layer.is

A library that supports all blend modes in Photoshop, brightness, contrast, hue, saturation, lightness adjustments, and curve adjustments on separate RGB channels.

Why use Layer.is?

  • Supports all frequently used blend modes in Photoshop
  • Chain operations (like jQuery)
  • Straightforward API to manipulate images
  • Load sequence of operations from JSON
  • Can apply curve adjustment selectively to RGB channels

Requirements

Layer.is requires Python 3.6 or higher.

Quick Start

Installation

Install layer-is from PyPI repository.

$ pip install layeris

Load/Save an image

Loading an image from file

from layeris.layer_image import LayerImage

image = LayerImage.from_file('/path/to/your/image.jpg')

Loading an image from URL

from layeris.layer_image import LayerImage

image = LayerImage.from_url('https://your-image-url')

Saving an image

image.save('output.jpg')

You can also specify the image quality between 0 - 100 by passing in the optional quality parameter. By default, quality is set to 75.

image.save('output.jpg', 90)

Basic operations

Grayscale

image.grayscale()

sample_grayscale

Blend mode operations

The descriptions for each blend mode operation are copied from https://helpx.adobe.com/photoshop/using/blending-modes.html.

Darken

Looks at the color information in each channel and selects the base or blend color—whichever is darker—as the result color. Pixels lighter than the blend color are replaced, and pixels darker than the blend color do not change.

grayscale_image.darken('#3fe28f')

sample_darken

Multiply

Looks at the color information in each channel and multiplies the base color by the blend color. The result color is always a darker color. Multiplying any color with black produces black. Multiplying any color with white leaves the color unchanged. When you’re painting with a color other than black or white, successive strokes with a painting tool produce progressively darker colors. The effect is similar to drawing on the image with multiple marking pens.

grayscale_image.multiply('#3fe28f')

sample_multiply

Color Burn

Looks at the color information in each channel and darkens the base color to reflect the blend color by increasing the contrast between the two. Blending with white produces no change.

grayscale_image.color_burn('#7fe3f8')

sample_color_burn

Linear Burn

Looks at the color information in each channel and darkens the base color to reflect the blend color by decreasing the brightness. Blending with white produces no change.

grayscale_image.linear_burn('#e1a8ff')

sample_linear_burn

Lighten

Looks at the color information in each channel and selects the base or blend color—whichever is lighter—as the result color. Pixels darker than the blend color are replaced, and pixels lighter than the blend color do not change.

image.lighten('#ff3ce1')

sample_lighten

Screen

Looks at each channel’s color information and multiplies the inverse of the blend and base colors. The result color is always a lighter color. Screening with black leaves the color unchanged. Screening with white produces white. The effect is similar to projecting multiple photographic slides on top of each other.

image.screen('#e633ba')

sample_screen

Color Dodge

Looks at the color information in each channel and brightens the base color to reflect the blend color by decreasing contrast between the two. Blending with black produces no change.

image.color_dodge('#490cc7')

sample_color_dodge

Linear Dodge

Looks at the color information in each channel and brightens the base color to reflect the blend color by increasing the brightness. Blending with black produces no change.

image.linear_dodge('#490cc7')

sample_linear_dodge

Overlay

Multiplies or screens the colors, depending on the base color. Patterns or colors overlay the existing pixels while preserving the highlights and shadows of the base color. The base color is not replaced, but mixed with the blend color to reflect the lightness or darkness of the original color.

image.overlay('#ffb956')

sample_overlay

Soft Light

Darkens or lightens the colors, depending on the blend color. The effect is similar to shining a diffused spotlight on the image. If the blend color (light source) is lighter than 50% gray, the image is lightened as if it were dodged. If the blend color is darker than 50% gray, the image is darkened as if it were burned in. Painting with pure black or white produces a distinctly darker or lighter area, but does not result in pure black or white.

image.soft_light('#ff3cbc')

sample_soft_light

Hard Light

Multiplies or screens the colors, depending on the blend color. The effect is similar to shining a harsh spotlight on the image. If the blend color (light source) is lighter than 50% gray, the image is lightened, as if it were screened. This is useful for adding highlights to an image. If the blend color is darker than 50% gray, the image is darkened, as if it were multiplied. This is useful for adding shadows to an image. Painting with pure black or white results in pure black or white.

image.hard_light('#df5dff')

sample_hard_light

Vivid Light

Burns or dodges the colors by increasing or decreasing the contrast, depending on the blend color. If the blend color (light source) is lighter than 50% gray, the image is lightened by decreasing the contrast. If the blend color is darker than 50% gray, the image is darkened by increasing the contrast.

image.vivid_light('#ac5b7f')

sample_vivid_light

Linear Light

Burns or dodges the colors by decreasing or increasing the brightness, depending on the blend color. If the blend color (light source) is lighter than 50% gray, the image is lightened by increasing the brightness. If the blend color is darker than 50% gray, the image is darkened by decreasing the brightness.

image.linear_light('#9fa500')

sample_linear_light

Pin Light

Replaces the colors, depending on the blend color. If the blend color (light source) is lighter than 50% gray, pixels darker than the blend color are replaced, and pixels lighter than the blend color do not change. If the blend color is darker than 50% gray, pixels lighter than the blend color are replaced, and pixels darker than the blend color do not change. This is useful for adding special effects to an image.

image.pin_light('#005546')

sample_pin_light

Non-blend mode operations

Brightness

Please note that this operation has yet to discover the exact algorithm (formula) used by Photoshop. However, the method used here is very close and extremely fast.

image.brightness(0.2)

Contrast

image.contrast(1.15)

Hue

image.hue(0.2)

Saturation

image.saturation(-0.5)

Lightness

image.lightness(-0.8)

Other utility methods

Getting image as NumPy array

image.get_image_as_array()

This will return a NumPy array with shape (height, width, 3). Note that the each pixel value is

Cloning a LayerImage instance

image.clone()

Roadmap

  • Add resizing capabilities using scikit-image.
  • Imitate Photoshop's auto brightness & auto contrast features
  • Add presets of filters

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

layeris-0.1.3.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

layeris-0.1.3-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file layeris-0.1.3.tar.gz.

File metadata

  • Download URL: layeris-0.1.3.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for layeris-0.1.3.tar.gz
Algorithm Hash digest
SHA256 575e1ea1510444bab2cc7dd2e7b507665c315e5d289681cd702799e36e0b1494
MD5 fc93f776c39d0fe33784594fcea7eb91
BLAKE2b-256 b87d8ea929a3e4f8c9ba74f44a29f2983054c9d2fcdea503d5693113b0bc2ffe

See more details on using hashes here.

File details

Details for the file layeris-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: layeris-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for layeris-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f4581ba45bdd461e1590fa02b4f38da7ffd95624f75e9d6a28a2bfb07bb73069
MD5 10b4580457e4537e7428db05e158d1fb
BLAKE2b-256 1007a4ca5265c1e3a5a6c0d83dbaae12b46047bfebeac855a7a9742b1a5edd7e

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