Subject: Re: Netscape Gif Pixel Transparent flag

From: [email-masked] (Gordon D B Cameron)
Date: Sun, 29 Jan 1995 00:30:55 GMT

In article <[email-masked]>, [email-masked] (Jasen M. Mabus) writes:
> Dear WWW users,
> 	Is there a package to change a white gif background into a transparent color? I have seen this done with a Graphic Control Extension.
> Jasen Mabus (http://www.rpi.edu/~mabusj)
> 

If you have the PBMplus toolkit, then just convert to ppm, then back to
GIF, using the right flags - you can change the GIF to be interlaced
like this also.

If you have PERL or similar, you could use something like the wee prog
below, which I use for this type of purpose :

#!/usr/local/bin/perl -s
#
#
# Take a gif file, and make it transparent, using the supplied colour
# 
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#
# VIDEO TOOLS - VERSION 1.0
#
# Gordon Cameron ([email-masked])
# Edinburgh Parallel Computing Centre
#
# Web Video Pages : http://www.epcc.ed.ac.uk/~gordonc/video_tools/intro.html
#
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

$tran_colour="white" ;			# Default transparent colour
$to_ppm="giftopnm";			# Converter from GIF -> PPM
$from_ppm="ppmtogif";			# Converter from PPM -> GIF

($my_name) = $0 =~ /([^\/]+)$/ ; # Get rid of slash nonsense at head of name

if ($h || $help || (@ARGV>1)) {
	print <<"EOHELP" ;
	Usage : $my_name <colour_specification>

	Takes a GIF as standard input, and produces a GIF89A as standard
	output, with the colour <colour_specification> made transparent in
	the output GIF. The colour can be specified by an X name, or
	by an R,G,B triple, where R, G and B are between 0 and 1.

	e.g.
		$my_name <in.gif 0,0,0 > out.gif
		$my_name <in.gif white > out.gif

EOHELP

	exit 1 ;
}

$tran_colour = $ARGV[0]
	if (@ARGV); 

open(PIPE,"|$to_ppm|$from_ppm -interlace -transparent $tran_colour") ;

while (<STDIN>) {
	print PIPE ;
}

close(PIPE) ;

-- 
~ Gordon Cameron ([email-masked])      ~  The rain in Spain, 
~ Edinburgh ||>arallel Computing Centre (EPCC) ~  falls mainly on the plain
~ __________||_____Tel (+44) 31 650 5024______  ~  whereas the rain in Scotland
~ http://www.epcc.ed.ac.uk/~gordonc/intro.html	 ~  falls, mainly