Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

3 examples of unusual ways to use PDF Image Masks

57 sec read

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!

Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

3 reasons Java developers switch to JDeli from ImageIO

ImageIO is build into the JDK and provides basic image support in Java. JDeli is a commercial image library for Java Developers from IDRsolutions....
Mark Stephens
1 min read

Why we wrote our own Java jpeg2000 libraries

JPEG2000 is an important image file format which offers significant benefits over JPEG. For our specific usage it does generate significantly smaller file sizes...
Mark Stephens
1 min read

How to choose JPG versus JPEG2000 for image files

Since we started to support both JPG and JPG2000 as image file outputs in our software, we have found that this is a very...
Mark Stephens
1 min read

One Reply to “3 examples of unusual ways to use PDF Image…”

Leave a Reply

Your email address will not be published. Required fields are marked *

IDRsolutions Ltd 2019. All rights reserved.