Page 1 of 3 123 LastLast
Results 1 to 10 of 30

Thread: Tutorial about generating transparent PNG's for use as tokens in a VTT or similar.

  1. #1
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,244
    Blog Entries
    8

    Tutorial Tutorial about generating transparent PNG's for use as tokens in a VTT or similar.

    This is part tutorial or at least the process by which I achieve them, part call for people to add how they do them and part gratuitous attempt to get rep points to recover my place with GP and keep ahead of Ascention. Ok not really, but since I know your all thinking that I thought id mention it first

    A chap who is using my app has discovered that to make tokens you need to make transparent images and is worried that he will spend half a lifetime drawing alpha transparency masks for all the images he wants to use. He is making a sci-fi world so I thought id use some non copyright NASA images to show what can be done and why its not going to take as long as one might initially think if you know a few tricks.

    I use PSP 7 which is old enough that it does not cope with transparent PNGs natively apart from the type which has a single color index assigned to clear - like GIF say. I believe its actually better to deal with the alpha mask or transparency layer as a separate image but then I am forced to. PSP7 can deal with images with transparency but it lacks the capability to save them in PNG format. I believe that later versions do not lack this file format problem and Gimp / PS users definitely don't have an issue. Also, image magick can deal with them easily too though I know I am of a small minority of people which use it.

    So back to basics and to recap some things which many will already know but its good to be complete here. Most image file formats have color information and no transparency information at all. These formats have red green and blue info or RGB. The common formats in this category are JPEG and BMP and both of these two can have full color images - like 16 million colors or so. Next up is GIF which holds 256 colors max - known as a color index format. You can optionally assign one of them to the transparent color. Then when viewed with the right viewer - like a web page browser (firefox / IE etc) it appears with 255 palette of discreet colours out of the 16 million possible and the one assigned to clear showing the background of the web page through the image. But that GIF is either totally clear or totally opaque. PNG has many colour options but the one we focus on is the RGBA where it has a channel called the Alpha channel and that is a greyscale layer assigned to transparency. So it can show any of the 16 million colors and it can also show them as fully opaque, fully transparent and also anything in between. In a VTT or stamp based tool you can use this effect to have image tokens which have a shape and fades - like fading out shadow portions of the image.
    Last edited by Redrobes; 02-22-2009 at 08:15 AM.

  2. #2
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,244
    Blog Entries
    8

    Post Simple cut out method

    Right, so lets say you have a pic off the web thats a non copyright image, CC or otherwise able to rip. Its RGB like a JPEG image and you want to make it into a PNG token with a cut out shape. Heres an example. HiRes pics from here http://grin.hq.nasa.gov/subject.html but I am using smaller versioned ones for examples.

    You could do this in a number of ways but this is the way I use. Starting with the X36 plane pic, look for a color that is definitely not in the image - like bright red. Get the single line tool and draw around it. What I tend to do is put the start point down near to where I want to start but a little away from the edge I am trying to follow. Then drag out the line and put the end point down exactly where I need it. Then without moving the mouse, start a new line and drag back to the starting point again but this time set the end point down exactly where it needs to be. The reason I do it this way is that you dont have to guess the angle exactly in one go. Like image below but end point 3 past the corner. Note, turn off anti aliasing for the line. Let it have jaggy edges. Otherwise it will blend red into the image and we will want to pick up the red in a mo.
    Last edited by Redrobes; 02-22-2009 at 07:47 AM.

  3. #3
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,244
    Blog Entries
    8

    Post

    So you have lined out the whole plane, use the selection magic wand tool and set the match color tolerance really high and pick a point in the background region of the plane. It should select all the background and up to but not including the red line. If its not hitting that then you need to adjust the tolerance. Normally something really high like 100 or so should do it tho if the red is sufficiently different to the image. Once that has done its thing then you can use the selection menu and use the expand selection by a few pixels - the number of pixels depends on the line size but basically set it to half the line width. If you have the 'marching ants' selection border showing it should now run through the middle of the red lines. Select the fill tool and set the fill match to none. Ie. Fill everything. Put that down in the background area and it should fill everything in the selection area giving a solid red background.
    Last edited by Redrobes; 02-22-2009 at 07:49 AM.

  4. #4
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,244
    Blog Entries
    8

    Post

    Touch up any missing little bits and then use the brightness tool to increase brightness by a large margin - like 50% or something like that.

    Then select the fill tool again, set the match tolerance to 0 and set the color to black. Fill the light red area to black.

    Now make the image greyscale using the color menu. Then use the brightness control again and add 127 brightness and 100% contrast. This should make everything not black into white. A touch of soften to smooth the edges down and your done.
    Last edited by Redrobes; 02-22-2009 at 07:50 AM.

  5. #5
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,244
    Blog Entries
    8

    Post

    Here is an example of the X36 token.
    Last edited by Redrobes; 02-22-2009 at 07:51 AM.

  6. #6
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,244
    Blog Entries
    8

    Post

    So that was a simple shape that had straight lines to cut out. How about something harder. This is not so bad *if* you can get a picture with a background color that is constant so that we can differentiate the image from its background. Images with a constant black or white background are best, then ones with all solid color. Here is the old and now burnt up Mir Space Station. Its pretty complicated to cut out but we can do most of that previous cut out process on it.
    Last edited by Redrobes; 02-22-2009 at 07:52 AM.

  7. #7
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,244
    Blog Entries
    8

    Post

    Take a copy of the color image and make a greyscale version of it. Soften it a little with a slight blur - maybe a few times. This reduces any noise in the image but you don't want to do it so that it looks very blurry. Now take that brightness option again and add as much brightness as you can with 100% contrast. In this case it was a lot - about 124. The more you can add without the background showing through the better. It depends on the pic in question though this one is with a near black background that allows us to go quite high. Once done then blur it a bit more and do again. This will expand the white to fill in small holes. By this point you can probably get out a brush and touch up the odd black dot in white and the odd white dot in black and remove stuff you don't want like the white in bottom right corner.

    Once its all solid black and white use the selection tool again on the white. Then contract the selection by a few pixels. We do this because we expanded the white earlier and we have been real aggressive in getting everything into the white areas. The amount to contract is a few pixels depending on the size of image and original color difference. Then invert the selection and flood the background with a match of 'none' again like before. Blur the edges just a little and save out the final alpha mask.
    Last edited by Redrobes; 02-22-2009 at 07:53 AM.

  8. #8
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,244
    Blog Entries
    8

    Post

    Here is an example of the Mir station token on a background.
    Last edited by Redrobes; 02-22-2009 at 07:54 AM.

  9. #9
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,244
    Blog Entries
    8

    Post

    And doing a few more like this here is collage of tokens on a background image with the astronaut floating away in the background. The big astronaut, planet and station are tokens on the top.

    Hope you enjoyed that and hope that some of you guys can add to that as to how you do the same thing.
    Last edited by Redrobes; 02-22-2009 at 07:55 AM.

  10. #10
    Community Leader Facebook Connected Steel General's Avatar
    Join Date
    Jun 2008
    Location
    Ft. Wayne, IN
    Posts
    9,530

    Default

    Nice job RR! *bonk*
    My Finished Maps | My Challenge Maps | Still poking around occasionally...

    Unless otherwise stated by me in the post, all work is licensed under a Creative Commons Attribution-Noncommercial 3.0 United States License.



Page 1 of 3 123 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •