Early this week, I wrote an introductory article about Masks. I would like to follow that with another article highlighting an issue which can occur with masks.
As explained before, a Mask is effectively a stencil which allows you to define which pixels are painted onto the page any how transparent they are. That is the easy bit – the problem is that the Mask and the Image can be very different sizes. It does not even need to have the same aspect ration. And there are quite a few tools which use this feature to achieve some interesting effects. Here are some examples:-
1. Specify an SMask as a 1 x 1 pixel image (the image is actually a much larger rectangle).
2. Specify a Mask with the same width as the image but a height of 1 pixel (the image is 900 pixels high).
3. Specify a large Mask and a 1×1 pixel image.
So the way we handle image Masks to cover these is to :-
- always use the bigger set of dimensions (whether on image or Mask)
- Scale the smaller to the larger with separate scaling on width and height
- Do not expect the Mask and the image to have the same aspect ratio
Have you come across and odd uses of image Masks in PDF files?
This post is part of our “Understanding the PDF File Format” series. In each article, we aim to take a specific PDF feature and explain it in simple terms. If you wish to learn more about PDF, we have 13 years worth of PDF knowledge and tips, so click here to visit our series index!