[prev in list] [next in list] [prev in thread] [next in thread] 

List:       graphicsmagick-help
Subject:    Re: [GM-help] help using -mask with 'convert'
From:       Bob Friesenhahn <bfriesen () simple ! dallas ! tx ! us>
Date:       2012-03-30 14:06:26
Message-ID: alpine.GSO.2.01.1203300852150.1678 () freddy ! simplesystems ! org
[Download RAW message or body]

On Thu, 29 Mar 2012, Marcos Ojeda wrote:

> hi there, 
> i have a question regarding using the -mask option with 'gm convert'
> 
> i have a tiny pdf that i'm converting like so:
> 
> gm convert -size '40x40' -resize '40x40' source.pdf output.png
> 
> i was hoping to apply a mask, to make a circle, so i made a white/black circle png \
> and then changed the command to 
> gm convert -size '40x40' -resize '40x40' -mask 'mask-40x40.png' source.pdf \
> output.png 
> but absolutely nothing changes. The output.png file remains the same, unmasked.
> 
> Is there something i'm missing? thanks for any help.

There is likely confusion about what GM's -mask actually does since 
'clipping mask' can mean so many different things.  The mask option 
provides a bitmap image which may be used to protect pixels from 
subsequent alteration if an additional processing/drawing operation is 
performed on the image.  The processing operation must not change the 
dimensions of the image since the image and the mask need to be the 
same dimensions in order for it to work.

The way the mask works internally is that pixels are copied to a 
temporary buffer, modified by the processing operation, and then 
selectively applied back to the final image based on the mask image. 
If a pixel is masked, then any change to it is discarded.

In practice, it is possible that there are some cases where the mask 
image may be lost and not applied at all.  It is wise to test to make 
sure the mask works as expected before relying on it.

The mask option does not cause anything special to be added to the 
output file.  Some file formats do support storing something called a 
'clipping mask' but GM's -mask does not do that.

As a source of further confusion, if a file does provide an embedded 
'clipping path' (an XML formatted string), the -clip option can be 
used to create a clipping mask image (similar to -mask) based on that 
embedded clipping mask.

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



------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure

_______________________________________________
Graphicsmagick-help mailing list
Graphicsmagick-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-help


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic