I’ve been pulling my hair out trying to figure out how to keep the transparency in my PNG images when I compile to ebook. No matter what I try, the end up compiling essentially as JPGs with white backgrounds. Is there a setting I’m missing somewhere? Or is this not supported?
There’s the option to downsize and resample images that might cause this effect. It’s in the Compile settings in the Options tab in the right-hand side column of the Compile Overview window.
Check if that option is checked…
You can always insert the PNGs in Sigil and make sure they are PNGs with transparency. This should work in e-books.
Just a guess, but I expect LL are just taking account of what Amazon does. When you upload an ePub to KDP, Amazon converts pngs to jpgs and removes transparency.
I never understood what Amazon’s reasoning is especially when, in their reading devices, they offer the choice of a background colour. When you select a non-white background, you see the white surrounds of the little images many authors use as section separators.
This gives a poor experience but then Amazon being the major sales outlet for books, what they decide goes for the whole industry, sadly.
To verify, this isn’t something Scrivener is doing, at least not with any settings I can think of, though I might be missing something. Even if you use the aforementioned downsampling option, it should be maintaining the original settings within the file and its file type. One exception is if the full conversion process does not handle the image type (which I test below by using SVG), but even then it should be using the safest conversion file type, which isn’t JPG since that is lossy and drops alpha channels.
The following test project has three test images, and these are the results:
- The original SVG file: again we will expect this to be converted as the process to ePub involves RTF at one point, which doesn’t handle it. So it gets converted to PNG 24-bit.
- A PNG 24-bit image: originally converted from the SVG program before placed into Scrivener.
- A PNG 8-bit image: converted from the above. This one will have jagged edges, because it is using simple 1-bit transparency.
I also added some CSS to draw a bright yellow background behind all figures, to verify that the opacity characteristics are intact. This was then compiled with the option enabled to save source files, so that the exported graphics themselves could be verified. There are two PNG-24 images (one being the SVG originally) and the PNG-8 image. When viewing the .epub in a reference viewer, we can see the yellow background around and behind the test image.
opacity_tests.zip (187.0 KB)
Of course, we can’t account for any damage a vendor may do to our ePubs when uploading them.
Yes, your images certainly retained their transparency, alpha layer. Good to have it confirmed that Scrivener does not remove it.