Search…

X3 Photo Gallery Support Forums

Search…
 
cmodesign
Topic Author
Posts: 2
Joined: 15 Nov 2023, 14:14

Change gallery background colour on transparent PNG images

16 Nov 2023, 11:32

I am trying to post transparent PNG logos in a Gallery. The Gallery view shows a black background behind the transparent image. However, when you click on an image to view the fullscreen popup, it shows a white background. Why is the background not consistently white?

Ideally, the background for transparent images would be light grey so that transparent logos with white graphics would appear. Is there a setting to change this or can I do this through customized CSS?
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13931
Joined: 30 Sep 2006, 03:37

Re: Change gallery background colour on transparent PNG images

16 Nov 2023, 21:43

cmodesign wrote:The Gallery view shows a black background behind the transparent image.
This happens when PHP resizes images with transparency (PNG or GIF) to a non-transparent format (JPG). The original transparent area just becomes a default non-color / black. If you really really need, it could be possible to adjust the transparency-background-fill color in X3 /app/parsers/slir/index.php, similar to the example code in this post.
cmodesign wrote:However, when you click on an image to view the fullscreen popup, it shows a white background. Why is the background not consistently white?
I'm not sure what white background this is, unless you set the popup background to white. When clicking to view a semi-transparent image in the popup, the transparent area will simply show the background color behind the image. I don't know what color this is on your X3 website, but by default it would be dark.

As you may understand, the resized image and the full image are therefore two separate things. We don't "assign" any background color to your original. It's transparent, and will therefore show whatever is behind it. Resized images on the other hand, resized by PHP on your server, will need to fill in the transparent background color into the rendered image. Normally, this is just black, and even if you change it, you can't just set it to "the same color as the original", because the original doesn't have any color, and will simply show whatever is behind the transparent area.
cmodesign wrote:Ideally, the background for transparent images would be light grey so that transparent logos with white graphics would appear. Is there a setting to change this or can I do this through customized CSS?
So, it could be possible to assign light grey for the small resized image, by ways of editing the PHP code. But no you can't assign this color to the full size image, as they will retain your original transparency. The only way for this, would be to perhaps assign the popup background color to be light grey.

As you can see, it's a bit complicated, but if you want to follow up, we can try to make it work.
 
metallissimus
Experienced
Posts: 318
Joined: 17 Oct 2019, 06:54

Re: Change gallery background colour on transparent PNG images

17 Nov 2023, 05:36

cmodesign wrote: Ideally, the background for transparent images would be light grey so that transparent logos with white graphics would appear.
If you want to show the actual content of the image in front of light grey, why don't you export and upload them with light grey background in the first place?

Maybe I misunderstood your intention, but for me this seems to be the easiest way.
www.danielbollinger.de – corporate photography
hochzeiten.danielbollinger.de – wedding photography