Menu

Blend Modes

The same old story…

Paperjs provides a number of blend modes for controlling how an effect (raster or text) is rendered onto the film sequence. The point of VOLPE is not to pre-render a film sequence, but to give as good an emulation as possible of the opening scene, so that position, size, and blending mode can be adjusted for the desired effect.

Once, however, the blend modes are produced by Paperjs, they need to be implemented as closely as possible in Imagick. And this is where the problems lay. Some Paperjs blend modes were quite easy to find in Imagick; others were completely orthogonal. Imagick has more blend modes than Paperjs, so that the formulae had to be discovered and implemented in a special version of Paperjs, VOLPaper, which is provided with this distribution .

Agreement: Paperjs blendmodes that could be implemented almost directly in Imagick

Normal

Imagick constant default.

VOLPaper Imagick
Add

Imagick constant plus.

VOLPaper Imagick
Color-burn

Paperjs code here was simplified by using Math.max() instead of a comparison. Imagick constant colorburn.

VOLPaper Imagick
Color-dodge

Paperjs code here was simplified by using Math.min() instead of a comparison. Imagick constant colordodge.

VOLPaper Imagick
Darken

Paperjs code here was simplified by using Math.min() instead of a comparison.

VOLPaper Imagick
Difference

Paperjs code here was simplified by using Math.abs() instead of a subtraction, comparison, and multiplication.

VOLPaper Imagick
Exclusion

Paperjs code here was simplified by using a multiplication instead of a repeated substraction.

VOLPaper Imagick
Hard-light

Imagick constant hardlight.

VOLPaper Imagick
Lighten

Paperjs code here was simplified by using Math.max() instead of a comparison.

VOLPaper Imagick
Multiply
VOLPaper Imagick
Minus
VOLPaper Imagick
Overlay
VOLPaper Imagick
Screen
VOLPaper Imagick
Soft-light

Imagick constant softlight.

VOLPaper Imagick

Where Imagick fails: Copying opacity

In a number of cases, Imagick produces very strange results where the overlaid image spills over into the translucent space. This could be remedied by copying the opacity channel onto the final image.

Colorize Hue Luminize Saturate
Color

Imagick constant colorize.

VOLPaper Imagick
Hue
VOLPaper Imagick
Luminosity

Imagick constant luminize.

VOLPaper Imagick
Saturation

Imagick constant saturate.

VOLPaper Imagick

Imagick blend modes that were added to VOLPaper

Divide
VOLPaper Imagick
Divide-src

This required copying opacity. Imagick constant dividesrc.

VOLPaper Imagick w/o opacity copying
Linear-burn

Imagick constant linearburn.

VOLPaper Imagick
Linear-light

Imagick constant linearlight.

VOLPaper Imagick
Pegtop-light

Imagick constant pegtoplight.

VOLPaper Imagick
Pin-light

Imagick constant pinlight.

VOLPaper Imagick
Vivid-light

This required copying opacity. Imagick constant vividlight.

VOLPaper Imagick w/o opacity copying
Darken-intensity

This required copying opacity. Imagick constant darkenintensity.

VOLPaper Imagick w/o opacity copying
Lighten-intensity

Imagick constant lightenintensity.

VOLPaper Imagick

Blend modes added to both Imagick and VOLPaper

Grain-extract

Imagick constant mathematics with corresponding formula.

VOLPaper Imagick
Grain-extract-src

Imagick constant mathematics with corresponding formula.

VOLPaper Imagick
Grain-merge

Imagick constant mathematics with corresponding formula.

VOLPaper Imagick
Divide-intensity

This required copying opacity.

VOLPaper Imagick w/o opacity copying
Multiply-intensity
VOLPaper Imagick
Negation-src
VOLPaper Imagick
Negation-sum
VOLPaper Imagick
Overlay-intensity
VOLPaper Imagick
Overlay-intensity-src
VOLPaper Imagick
Screen-intensity
VOLPaper Imagick
Screen-intensity-src
VOLPaper Imagick

Blend mode that failed to produce anything reasonable in Paperjs

Negate
PaperJS original VOLPaper Imagick

Blend mode that failed to produce anything reasonable in Imagick

Subtract

The use of the subtract constant resulted in an unusable image which was identical to the result produced by modulussubtract, but minussrc worked as intended.

VOLPaper Imagick Imagick original

Blend mode that produced insufficient agreement between Imagick and Paperjs and was not implemented

Hard-mix
VOLPaper Imagick

Notes

  1. While results are not 100% identical, care has been taken to achieve an effect that is as near as dammit. Images can be overlaid with grain extract to determine any deviations, but keep in mind that Paperjs's pixel positions are rarely integers, and minor differences will be found. Also, as I have complained to the makers of Paperjs, Paperjs applies an undetermined gamma to all images, brightening them in the mid ranges by about 5%.
  2. "Intensity" modes are based on a gray-scaling according to the rec601luma formula (0.299/0.587/0.114 for RGB).
  3. "Src" modes are analogous to Imagick's "SRC" modes in defining source and destination images.
  4. All Imagick constants require a leading string "imagick::COMPOSITE_".
  5. Blend modes that were not used are all the Duff-Porter modes (destination_*, source_*) and average (since this can be emulated by "normal" and setting the opacity to 0.50).



Related

Wiki: Mission Statement

MongoDB Logo MongoDB