Why do some, but not all, PNG files (with transparency) in InDesign documents have black borders?
When I put PNG images into an InDesign document, sometimes they have black borders on the exported PDF. Usually this doesn't seem to be a problem in print but in a recent proof, I did see some of the issue surfacing there too (albeit not quite as bad). However... Even if it's not as bad in print, it'd be nice to not occur in the PDFs too as these get sent out to customers via email too.
Now I know what people are going to say here... PNGs are a web format and not for print! I agree! I'm slowly converting people over to TIF/PSD here.
The catch here is that I don't get this problem with all of the PNG files. Some are absolutely fine. I've noticed that in the links panel of InDesign that some have black backgrounds and some have white backgrounds (presumably the alpha layer doesn't show up in the links panel). Why are some of these PNG files showing up perfect and others not? I can't seem to see the difference between the files in Photoshop.
To illustrate this issue, screenshots and photos follow:
Here's a PNG placed into an InDesign Document:
Note the black background that this file has in the links panel.
Here's the same section on a PDF export of this document (PDF/X-4:2014, Average downsampling to 300dpi for images over 350, compression:JPEG, quality:Maximum):
And here's what it looks like when zoomed in:
Finally, here it is on the proof:
The right side of the bottle has dark bits along the edge.
Now here is another PNG in the same document:
There's a white background in the links panel for this file.
And here's how it looks in the same PDF:
No black borders at all on the PDF and no black edge on the print either:
There's a short answer here and that's to use TIF files and your problems will go away...
But if people would still like to know more, I'll try to explain what's actually happening. It is likely that these files are different since being created in different programs. It doesn't appear that one is "wrong" as such (I'll explain that later). It just seems to be a way that PNGs work and how they clash with PDFs. Different programs have different default settings and some must just add a black background.
In Photoshop, using Layer > Layer Mask > From Transparency we can split the transparency layer off from the image and we see that this particular file has a black background underneath:
This isn't really that much use to us right now but this reveals the hidden black background in Photoshop (InDesign isn't just imagining it!). The alpha channel (transparency layer) is slipping out of alignment with the rest of the image when embedded into a PDF, causing us to be able to see some of that (usually) hidden black background when viewed on screen. It's unlikely to cause much effect in final print (though as we've seen, there is a little)... It's mostly an on screen issue.
As the hidden black background is already there, copying the image into a new document won't do anything. However we can replace that background with a different colour so when the transparency alpha layer slips, we don't see it as easily. Any colour can go in here but we want to use a colour that isn't contrasting to the image and whatever you're placing it on top of. I've added a flat white layer below the image and masked everything again here:
Below is a comparison of the different versions. The mystery black background version on the left and modified version with a white background in the middle. You can see how there's far less issues with the white background when the image is so light.
I mentioned that the hidden black background wasn't exactly wrong... The reason is that if an image with a hidden white background is placed on a dark page, you see a white halo instead as the transparency alpha layer slips:
And also, finally, that very shiny, perfect TIF. :D