How do I make an image's background transparent?

The place for chatting and discussing subjects unrelated to Wesnoth.

Moderator: Forum Moderators

Post Reply
User avatar
Monroid
Posts: 157
Joined: May 15th, 2010, 9:03 pm

How do I make an image's background transparent?

Post by Monroid »

It's for my avatar, and as you may see, it has a white square on the background

What should I do so it'll be transparent?
User avatar
Hulavuta
Posts: 1668
Joined: October 11th, 2008, 8:17 pm
Location: United States

Re: How do I make an image's background transparent?

Post by Hulavuta »

You should download GIMP, but there might be some websites that you can do it on.

However, making it transparent increases the file size. I tried making a picture that was 3kib transparent, and it made it 10kib which is over the limit.
F:tGJ, Saurian Campaign
The Southern Chains, a fanfic
“The difference between winners and champions is that champions are more consistent."
~Sierra
User avatar
ancestral
Inactive Developer
Posts: 1108
Joined: August 1st, 2006, 5:29 am
Location: Motion City

Re: How do I make an image's background transparent?

Post by ancestral »

Some graphics programs will allow you to select all pixels of a single color. Like Pixelmator.

How's this? (I assumed the blade's white pixels should be white and not transparent ;-) )

Image
Wesnoth BestiaryPREVIEW IT HERE )
Unit tree and stat browser
CanvasPREVIEW IT HERE )
Exp. map viewer
User avatar
Iris
Site Administrator
Posts: 6798
Joined: November 14th, 2006, 5:54 pm
Location: Chile
Contact:

Re: How do I make an image's background transparent?

Post by Iris »

Hulavuta wrote:However, making it transparent increases the file size. I tried making a picture that was 3kib transparent, and it made it 10kib which is over the limit.
There are more tricks than that. You can switch to an indexed format. With some tinkering you can get a reasonable result with even less than 256 colors, which you can then use as an avatar because certainly no-one is going to look at every single pixel of it.
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm.
User avatar
Monroid
Posts: 157
Joined: May 15th, 2010, 9:03 pm

Re: How do I make an image's background transparent?

Post by Monroid »

ancestral wrote:Some graphics programs will allow you to select all pixels of a single color. Like Pixelmator.

How's this? (I assumed the blade's white pixels should be white and not transparent ;-) )

Image
Yup! :D

And thanks a lot, it's working alright now
User avatar
Captain_Wrathbow
Posts: 1664
Joined: June 30th, 2009, 2:03 pm
Location: Guardia

Re: How do I make an image's background transparent?

Post by Captain_Wrathbow »

As long as the question's answered, could I drag this a little off-topic? :P
shadowmaster wrote:There are more tricks than that. You can switch to an indexed format. With some tinkering you can get a reasonable result with even less than 256 colors, which you can then use as an avatar because certainly no-one is going to look at every single pixel of it.
Coming from a total art noob: What is an indexed format?
User avatar
Cloud
Art Contributor
Posts: 502
Joined: December 17th, 2008, 7:43 pm
Location: The land of pixels
Contact:

Re: How do I make an image's background transparent?

Post by Cloud »

Something to do with indexing all the colours in the images (or merging very similar colours) to reduce the size of the image. .gifs I know use indexing.

As an aside - GIMP 2.4 (and I assume it's similar in later versions) has the option to change the mode in image->mode->(RGB, Greyscale or Indexed). Useful when you're playing around with gifs and want to keep the shadow at the right colour with a background.
Softly/SoftlySplinter on IRC. Will be lurking around more these days
Mainline Animations|The Væringjar
Art for these mead-sodden, bearded mushroom-junkies by Girgistian!
User avatar
Captain_Wrathbow
Posts: 1664
Joined: June 30th, 2009, 2:03 pm
Location: Guardia

Re: How do I make an image's background transparent?

Post by Captain_Wrathbow »

Ah, okay. Thanks. :)
User avatar
Iris
Site Administrator
Posts: 6798
Joined: November 14th, 2006, 5:54 pm
Location: Chile
Contact:

Re: How do I make an image's background transparent?

Post by Iris »

Captain_Wrathbow wrote:Coming from a total art noob: What is an indexed format?
I know Cloud replied above, but I'll explain anyway.

Indexed images represent every single pixel as a number (generally a byte, so a number between 0 and 255) that refers to an entry in an embedded or external palette where that index is associated to the actual color value. This is opposed to the regular/more intuitive non-indexed representation in which every single pixel is a complete color value, which for RGBA (RGB+alpha) images would theoretically take 4 bytes for every single pixel.

Indexation like this allows to save lots of space if color values repeat a lot, which tends to be the case for pure pixel art/sprites. Note that regardless of the image's internal representation, PNG can use compression algorithms on the pixmap data for storage in files or streams.

The Wikipedia article on the PNG format may be an interesting reading if you want to know more about this stuff.

FWIW I always convert my avatars to indexed PNGs. It can save lots of space even for images that don't use an alpha channel — say, from 20 KB to 9 KB. Again, since they are avatars, I don't have a problem with going for lossless conversion, so I might use only palettes of 128 colors or less instead of the full 256.

Anyway, I don't really expect artists to know this stuff. However, since I've had to deal with the reference (“official”) PNG interface (libpng) directly...
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm.
Post Reply