How to change the background color of an image?

Asked

Viewed 469 times

-1

I need to change the white background color of images using programming. Does anyone know how to proceed?

  • Is it possible that the comrade who denied the question explains why he did it? The question is misspelled, is posted in the wrong place or is it just because you do not know how to answer?

  • Hello @Vitor André, (already getting rid it was not me who voted negative kkk), but your question is with a lot of unnecessary information, try to edit your question and objectively show your problem, without this part of something you did in the past but do not remember(if you don’t remember imagine us? rsrsrs). For example, if your goal is to change the background of an image (I assume it’s the <img> tag) use the background-color property of css.

  • Thanks Bruno. I’m going to edit. The intention was just to relax, but okay, you’re right. Anyway, my idea is to change the white background color of a series of images that will be added on a slide. The user will not edit his images to have the carousel background color and also does not want to use white background on the carousel. So I’m trying to find a solution for him. I found a solution using Javascript in Stackoverflow in English, but it only works on Html5 and wanted a little more versatile, because as I said I used a similar solution in the past.

  • Your question has become much more objective now, I fully agree with Bruno’s words. He had a lot of unnecessary information and ended up taking the focus of the real problem. I’m sorry I voted against, the fact that you have returned and worried about editing shows you commitment. I will withdraw the vote against.

  • Thank you Simão. And I only questioned the negative vote because there was no feedback. But yes, I think it’s important to collaborate with the community and follow the guidelines. Thanks again.

  • Is there a test page to see if the background that appears is really from the photo? Because it could be another element that is causing this.

Show 1 more comment

1 answer

1

Try this

<img class="suaclasse" src...>

css

img.suaclasse {
  background-color: rgba(0,0,0,0); // ou uma cor que você preferir.
}

  • Bruno, nice solution. I had forgotten it. But I wanted to change a jpg image. Or a png without transparency.

  • What happens is that the customer will register images for a slide (carousel). It won’t edit every image you take and remove background or just look for images with transparent background - it would be nice if you did, but I have to tell you it won’t. So I wanted a way to swap the white background for the color of the slide background, you know? Because then I put as a requirement that the images have white background there, which does not require knowledge of the client and does not take time.

  • Swap the image itself, there is no way (unless someone comes up with an innovative tetin there kkkk), you can set a fixed background color on the slide and ask the photos to have the same color.

  • Here’s a solution, but it works with canvas (Html5) and I wanted to see if I could find a cross browser solution. http://forum.imasters.com.br/topic/479112-resolvidomudar-cor-da-imagem/

  • This one I won’t know how to answer because I’ve never done it (let alone know how to use canvas ;p).

  • Beauty. Thanks Bruno. This doubt is not very trivial even... Thanks for the attention.

  • Need something else we’re there.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.