Forum How do I...?

colorize image

ixgal
Hello,

Is it possible to use some property or parameter in PrinceXML, so that a grayscale image appears colorized in the PDF output?

Thanks
mikeday
There are CSS and SVG filters, but how do you want to colorize it? There is no filter that will automatically make a black and white photo look like a color photo, that takes human editing.
ixgal
Please see the 2 images attached. I would like to use some CSS property so that the grayscale image appears as the color image in the PDF output. Thanks
ixgal
(attachment here)
  1. color.jpg41.3 kB

Edited by ixgal

wangp
You could try a combination of sepia and hue-rotate filters:
filter: sepia(0.5) hue-rotate(75deg)

Or use SVG:
<svg width="512" height="238" viewBox="0 0 512 238">
    <filter id="Table">
      <feComponentTransfer color-interpolation-filters="linearRGB">
        <feFuncR type="linear" slope="0.8"></feFuncR>
        <feFuncG type="linear" slope="1.4"></feFuncG>
        <feFuncB type="linear" slope="0.9"></feFuncB>
      </feComponentTransfer>
    </filter>

    <image x="0" y="0" width="100%" height="100%"
        preserveAspectRatio="false"
        filter="url(#Table)" href="color.jpg"/>
</svg>

It's probably possible to design an SVG filter that more closely matches your example, but I don't know how.