Package: layeris
Layer.isA 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 PhotoshopChain operations (like jQuery)Straightforward API to manipulate imagesLoad sequence of operations from JSONCan apply curve adjustment selectively to RGB channelsRequirementsLayer.is requires Python 3.6 or higher.Quick StartInstallationInstall layer-is from PyPI repository.$pipinstalllayerisLoad/Save an imageLoading an image from filefromlayeris.layer_imageimportLayerImageimage=LayerImage.from_file('/path/to/your/image.jpg')Loading an image from URLfromlayeris.layer_imageimportLayerImageimage=LayerImage.from_url('https://your-image-url')Saving an imageimage.save('output.jpg')You can also specify the image quality between 0 - 100 by passing in the optionalqualityparameter. By default,qualityis set to 75.image.save('output.jpg',90)Basic operationsGrayscaleimage.grayscale()Blend mode operationsThe descriptions for each blend mode operation are copied fromhttps://helpx.adobe.com/photoshop/using/blending-modes.html.DarkenLooks 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')MultiplyLooks 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')Color BurnLooks 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')Linear BurnLooks 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')LightenLooks 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')ScreenLooks 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')Color DodgeLooks 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')Linear DodgeLooks 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')OverlayMultiplies 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')Soft LightDarkens 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')Hard LightMultiplies 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')Vivid LightBurns 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')Linear LightBurns 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')Pin LightReplaces 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')Non-blend mode operationsBrightnessPlease 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)Contrastimage.contrast(1.15)Hueimage.hue(0.2)Saturationimage.saturation(-0.5)Lightnessimage.lightness(-0.8)Other utility methodsGetting image as NumPy arrayimage.get_image_as_array()This will return a NumPy array with shape (height,width, 3). Note that the each pixel value isCloning a LayerImage instanceimage.clone()RoadmapAdd resizing capabilities using scikit-image.Imitate Photoshop's auto brightness & auto contrast featuresAdd presets of filters