![]() |
#1 |
Enthusiast
![]() Posts: 38
Karma: 10
Join Date: May 2025
Device: iPad
|
How to Handle Transparent Images for Dark Mode?
I have some transparent PNG images (text-dividers and simple grafics). These images are no pictures but only simple drawings.
Since I wanna make sure that they can be seen and read in dark mode as well I've created two versions, one with black lines and text for the light mode and one in white for the dark mode. Both images have a transparent background to fit in nicely in the current active desgin. While Apple Books displays the images correctly, Google Play Books won't comply in dark mode. Although Google Play Books grabs the intended image for the dark mode, it will add a light background to it for no reason, making the image a light square and completely unreadable, since the image for the dark mode consists only of white content. How can I insist Google Play Books to keep their fingers off the image and leave it in original state? I'll get it, that Google thinks we developers are too stupid to cover these details, but what, if there are some eBook creators out there in the wild who actually know what they are doing (or at least think to know)? I don't wanna create an extra version for dark mode without transparent background but dark background, since the background color set on the device varies. How do you guys handle this issue for readers which do alter transparent images? For testing reasons I've added an eBook which contains a text-divider which serves for both light and dark mode (the grafic is black and white for this purpose), and a line drawing in two versions, one for light and one for dark. |
![]() |
![]() |
![]() |
#2 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,736
Karma: 8700123
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
I made some minor modifications to the epub you uploaded, and it works in CHROME and FIREBOX ![]() 1. Open the epub in Sigil. 2. Right-click on the Section0001.xhtml sheet and select "Open with..." 3. Choose to open that file with Chrome or Firefox. Why did I tell you to open that sheet with one of those browsers? Because they handle "@media (prefers-color-scheme: dark)" well, and if you change the light mode to dark mode and vice versa, you'll see that everything appears as expected. The problem is e-readers that don't respect @media and don't detect the change to dark mode. |
|
![]() |
![]() |
![]() |
#3 |
Enthusiast
![]() Posts: 38
Karma: 10
Join Date: May 2025
Device: iPad
|
This is great advice, many thanks. I'd have to make some smaller additional changes since pure white is too much of a contrast, but modern CSS filter might be a viable way.
The problem with Google Play Books was not that it didn't respect the media query but altered the background without any reason. Google might be thinking to provide a better contrast, but dind't realize there was a specific image exactly for that purpose. Now, let me ask the 1 million dollar question: what will Kindle do? Is Kindle able to manage media queries and modern CSS like "filter: invert" etc.? And what about the other usual readers, can they handle this solution, or might it still bebetter to provide 2 distinct images for light and dark? |
![]() |
![]() |
![]() |
#4 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,346
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
You can also try using a mask. This was talked about a bit in this thread.
and here. That allows the image to be seen regardless of the light/dark mode, and you don't need to make multiple images. |
![]() |
![]() |
![]() |
#5 | |||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,736
Karma: 8700123
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
![]() Quote:
Quote:
|
|||
![]() |
![]() |
![]() |
#6 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,736
Karma: 8700123
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#7 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,346
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
I didn’t look recently, but I thought using the mask tied the mask color to the font color. Whatever color was selected with the theme would change the image. It didn’t specifically react to just background color.
|
![]() |
![]() |
![]() |
#8 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,736
Karma: 8700123
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
And you are right. In Sigil, it works as expected but in ereader, it doesn't. Do the try in Thorium or Calibre Viewer, change the color theme and you'll see how masks work (or better said, don't work). The solution you posted is bright, a real pity that ereaders don't honor it.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Comfy Dark Mix (Dark mode only) | Comfy.n | Calibre | 30 | 12-01-2024 10:23 PM |
Trouble with transparent images | erasmix | Writers' Corner | 0 | 06-04-2023 02:00 AM |
Randomly changing from Dark Mode to Light Mode | C8H10N4O2 | Calibre | 2 | 07-28-2022 09:36 PM |
Bug: Dark Mode (Windows) Book Details Pop-Up Cover Background Not Changing to Dark | cgrapski | Calibre | 7 | 05-03-2021 11:45 PM |
Transparent images | Iznogood | ePub | 3 | 12-31-2012 08:38 PM |