Menu

reduce opacity on whole image troubles

Help
Erik
2015-11-18
2015-11-19
  • Erik

    Erik - 2015-11-18

    Following example by Bob here http://superuser.com/a/444959/3189 I am having trouble modifying the opacity on a whole image.

    The image is here: https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png

    I am trying to cut the opacity by 50%.

    So I try:
    gm convert PNG_transparency_demonstration_1.png -operator Opacity Multiply 0.5 output.png

    But it converts the completely transparent pixels to translucent grey instead of keeping their complete transparency. How to reduce the opacity by half but keep what is already transparent transparent?

    Much thanks.

    [GraphicsMagick 1.3.22]

     
    • Bob Friesenhahn

      Bob Friesenhahn - 2015-11-19

      On Wed, 18 Nov 2015, Erik wrote:

      I am trying to cut the opacity by 50%.

      So I try: gm convert PNG_transparency_demonstration_1.png -operator Opacity Multiply 0.5 output.png

      But it converts the completely transparent pixels to translucent grey instead of keeping their complete transparency. How to
      reduce the opacity by half but keep what is already transparent transparent?

      I have not looked at the image yet, but it is important to know that
      opacity is the inverse of transparency and the values are stored as
      opacity. Try using (untested):

      -operator Opacity Negate 0 -operator Opacity Multiply 0.5 -operator Opacity Negate 0

      This should cause the multiplication to reduce levels in the correct
      direction.

      Another useful command is -recolor with a 4x4 or 5x5 matrix, but it
      has similar issues. However, -recolor uses double-precision floating
      point internally and negative values are allowed.

      Perhaps it would be good to add a Transparency operator which operates
      on transparency rather than Opacity.

      Bob

      Bob Friesenhahn
      bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
      GraphicsMagick Maintainer, http://www.GraphicsMagick.org/

       
      • Erik

        Erik - 2015-11-19

        Wow, that did the trick (-operator Opacity Negate 0 -operator Opacity Multiply 0.5 -operator Opacity Negate 0). Thank you!

         

Log in to post a comment.