My original post isn't showing up. In case it got eaten because of the included bash scripts, here is an edited version... After trying to copy Pawn images from the PDF file and getting black backgrounds, I found a few old threads about the issue. http://paizo.com/threads/rzs2q50z?Black-Background-in-Copy-and-Pasted-Image s
While a couple of the suggestions did sort of work, they weren't perfect and I couldn't find a satisfying explanation as to why. It seemed more like some arcane ritual than a technological operation. I did some more digging, and I thought I'd post what I found in case someone finds it helpful. Maybe this is all well-known, but it didn't pop right out in my search. First, I found the following post that states that images in a PDF file do not have an alpha channel. Instead, a second image is used as a mask. The linked specification document was too dense for me, but this would make sense. If some programs copy the image without merging the mask, they would lose the alpha channel. This would also explain why extraction with pdfimages outputs two files for an image. Helpfully, someone posted a script for extracting and appying an alpha mask image. https://gist.github.com/innermond/d110d6234123bf87cc04 The script makes some assumptions that won't work with Paizo's PDF files, but the key commands I adopted are: Quote:
The result is an image with a proper transparent background. I'm running these under Linux, but any program that extracts the image and mask can take the place of pdfimages. Convert is a command line tool from imagemagick, but I imagine you could do the same thing manually using Photoshop or Gimp. Obviously I can't post any examples of the resulting image, but hopefully this is explicit enough for people to follow.
After trying to copy pawn images from the PDF file and getting black backgrounds, I found a few old threads about the issue. http://paizo.com/threads/rzs2q50z?Black-Background-in-Copy-and-Pasted-Image s
While a couple of the suggestions did sort of work, they weren't perfect and I couldn't find a satisfying explanation as to why. It seemed more like some arcane ritual than a technological operation. I did some more digging, and I thought I'd post what I found in case someone finds it helpful. Maybe this is all well-known, but it didn't pop right out in my search. First, I found the following post that states that images in a PDF file do not have an alpha channel. Instead, a second image is used as a mask. The linked specification document was too dense for me, but this would make sense. If some programs copy the image without merging the mask, they would lose the alpha channel. This would also explain why extraction with pdfimages outputs two files for an image. Helpfully, someone posted a script for extracting and appying an alpha mask image. https://gist.github.com/innermond/d110d6234123bf87cc04 The script makes some assumptions that won't work with Paizo's PDF files, but the key commands I adopted are: Quote:
The result is an image with a proper transparent background. I'm running these under Linux, but any program that extracts the image and mask can take the place of pdfimages. Convert is a command line tool from imagemagick, but I imagine you could do the same thing manually using Photoshop or Gimp. Obviously I can't post any examples of the resulting image, but hopefully this is explicit enough for people to follow. Here are a couple of quick scripts I threw together using those commands. Sorry about the formatting, but it looks like Paizo doesn't accept [code] tags.
Quote:
This one takes in the name of an image and a mask and merges them: Quote:
|