0

We have an upload form for clients to upload their logos, but many clients don't know how to save a PNG with transparency, so we often get white "backgrounds" behind white text, which is totally unusable. So I would like to add some javascript to check if the png has a transparent background, and then reject the form if it does not (or vice versa).

Can that be done on the client side or the server side?

Thanks.

Paeon
  • 85
  • 1
  • 8
  • What if the image itself is white haha? Your question is kind of vague because it can be answered in multiple ways, each one being entirely different from the other. 1. You could implement a very simple neural network to try and detect if the image has a lot of white pixels. 2. You could create a simple form asking the client if the image they are about to upload has transparent background. Do you see how those 2 solutions differ from one another? I suggest you try to come up with a solution on your own or maybe ask in another stack exchange website. – ZombieChowder Mar 31 '22 at 18:28
  • 1
    There are a few ideas here - https://stackoverflow.com/questions/41287823/check-image-transparency. Checking the file header as mentioned tells you if that particular PNG supports transparency, but not whether it has any. You'd probably have to load the image into a canvas and check some pixels. – James Mar 31 '22 at 18:39

0 Answers0