61

How can I set a transparent background on JPEG image? This is a doubt of many colleagues of mine.

What would be the solution using Paint on Windows?

What are the other simple alternatives?

1

7 Answers 7

85

You can't make a JPEG image transparent. You should use a format that allows transparency, like GIF or PNG.

Paint will open these files, but AFAIK it'll erase transparency if you edit the file. Use some other application like Paint.NET (it's free).

Edit: since other people have mentioned it: you can convert JPEG images into PNG, in any editor that's capable of working with both types.

9
  • 3
    This comment is for anyone with the same doubt: Yes. I just installed Paint.NET and it's really very simple... You just need to open the image, select white area with the magic wand and delete it.
    – arms
    Commented Jun 3, 2013 at 21:45
  • 3
    Careful with that, though. Depending on the sensitivity of the wand, and the color gradient, you might still get an "aura", or lots of small squares, both the color of the original background. This will be more noticeable if the image is set against a background that's the opposite color of its original one. It takes only a wand selection and a deletion to make things transparent, but it takes some hand work to make stuff look nice.
    – Geeky Guy
    Commented Jun 3, 2013 at 21:48
  • 1
    Don't tell like this… I just added a transparent channel to a test image, wrote a word with an eraser in GIMP, next saved it in «.jpg». When I opened it again with GIMP, I indeed didn't saw the word. It seemed that you were right… But know what? I found that the image still hold the transparent channel! Next I choose the tool «filling», and pressed with this somewhere in the area with my transparent word — and it did appeared!
    – Hi-Angel
    Commented Dec 19, 2014 at 18:33
  • arms -- what do you mean by 'delete it'? Delete what? Where is there a 'delete'? Please clarify.
    – tale852150
    Commented Jan 15, 2015 at 2:31
  • 1
    @MysteryPancake JPEG 2000 is not JPEG.
    – Geeky Guy
    Commented Mar 25, 2018 at 16:18
41

If you’re concerned about the file size of a PNG, you can use an SVG mask to create a transparent JPEG. Here is an example I put together.

2
  • 2
    I can't believe I only saw this now. Awesome answer.
    – Geeky Guy
    Commented Mar 9, 2017 at 18:39
  • 4
    And here is another SVG example using clipPath (some comments therein may be useful). Commented Jan 22, 2018 at 15:11
20

JPEG can't support transparency because it uses RGB color space. If you want transparency use a format that supports alpha values. Example PNG is an image format that uses RGBA color space where (r = red, g = green, b = blue, a = alpha value). Alpha value is used as an opacity measure, 0% is fully transparent and 100% is completely opaque. pixel.

0
11

JPG does not support a transparent background, you can easily convert it to a PNG which does support a transparent background by opening it in near any photo editor and save it as a.PNG

8

How can I set a transparent background on JPEG image?

If you intend to keep the image as a JPEG then you can't. As others have suggested, convert it to PNG and add an alpha channel.

6

Just wanted to add that GIF "transparency" is more like missing pixels. If you use GIF then you will see jagged edges where the background and the rest of the image meet. Using PNG, you can smoothly "composite" images together, which is what you really want. Plus PNG supports highly quality images.

Don't use "Paint". There are many high quality art applications for doing art work. I think even the cell phone apps (Pixlr is pretty good and free!) and web-based image editting apps are better. I use Gimp - free for all platforms.

While a JPEG can't be made transparent in and of itself, if your goal is to reduce the size of very large image areas for the web that need to contain transparent image areas, then there is a solution. It's a bit too complicated to post details, but Google it. Basically, you create your image with transparency and then split out the alpha channel (Gimp can do this easily) as a simple 8-bit greyscale PNG. Then you export the color data as a JPG. Now your web page uses a CANVAS tag to load the JPG as image data and applies the 8-bit greyscale PNG as the Canvas's alpha channel. The browser's Canvas does the work of making the image transparent. The JPEG stores the color info (better compressed than PNG) and the PNG is reduced to 8-bit alpha so its considerably smaller. I've saved a few hundred K per image using this technique. A few people have proposed file formats that embed PNG transparency info into a JPEG's extended information fields, but these proposal's don't have wide support as of yet.

5

JPG doesn't support transparency

Not the answer you're looking for? Browse other questions tagged or ask your own question.