<OBJECT> element, and PNG graphics-files
The <OBJECT> element.
This has been suggested by W3C as an alternative to the <IMG> tag for
in-lining images; and recommended to supersede the <APPLET> element
for Java objects.
Its potential flexibility implies that it may become used for yet more
types of "object" in the future.
The syntax is:
<OBJECT attributes> Alternative action </OBJECT>
where "attributes" are described below; and "Alternative action" is
skipped over unless the <OBJECT> is not implemented -- in this case,
it is equivalent to the ALT= attribute in an <IMG> tag except that it
is not restricted to text, but can be (almost) any valid HTML, even
including a further <OBJECT> element (as it is allowed to be nested).
Attributes for any type of Object
- WIDTH=
- width of rendered area in pixels;
- HEIGHT=
- height of rendered area in pixels.
- BORDER=
- width of border line drawn round area ("0" for none).
- HSPACE=
- horizontal gutter in pixels;
- VSPACE=
- vertical gutter in pixels.
- ALIGN=
- vertical or horizontal alignment, eg "top", "left" etc.
- STANDBY=
- text to display while fetching/loading object.
Attributes for graphics/images
- TYPE=
- specifies the type of image file, eg
"image/gif", "image/jpeg" or "image/png".
- DATA=
- gives the URL reference to the image file, eg
"piccy.gif" or "../images/photo.jpeg" etc.
Attributes for code applets
- CODETYPE=
- specifies the particular "language" the applet is coded in
(ie it is not restricted to just Java).
- CLASSID=
- specifies the URL reference to the applet code;
- CODEBASE=
- specifies the Base URL if CLASSID was just a leafname not in the
current directory.
- DATA=
- specifies the URL reference to data for the code (if required).
PNG image files.
This stands for "Portable Network Graphic"; and is pronounced "Ping".
W3C propose that this file format could replace the current GIF format,
for two main reasons:
- GIF is getting a bit old (in computing terms); and the increasing
number of "variations" has made it progressively less "standardised";
- Unisys and Compuserve claim Patent and Copyright (respectively);
OK, you and I know that nowhere in the civilised world can you patent
an algorithm -- but hey, the U.S.ofA. is involved here; as a result,
W3C have never been able to formally endorse/recommend the GIF format,
but the new PNG is known to be free of "legal encumbrances".
This brief overview of the PNG format indicates:
- Functions which replicate those available in GIF;
- Enhancements/expansions to GIF facilities;
- Brand new additions; and
- Features which PNG deliberately does not support.
Basic features:
- It is a bit-map file;
- Lossless compression is used to minimise file-size;
- There may be 2, 4, 16 or 256 "logical" colours, indexing into a palette;
- The palette can be 8 bits per colour (24-bit "depth");
- One "colour" may be declared as being transparent;
- Data may be "interlaced" (allowing an image to build up from low
resolution to high resolution during fetching).
Extended features:
- A 256-greyscale can be used (which doesn't need a palette);
- The palette can be 16 bits per colour (48-bit "depth");
- Interlacing now makes the lo-res image appear "squared", not "stripey".
Additional features:
- The file has a "chunk" structure, to implement all these additions;
- Each pixel can be defined by a colour-triplet "TrueColour", of either
24 or 48 bit depth (palette not normally then used);
- There can be a full "Alpha channel": each pixel can have an 8-bit
"opacity", for making translucent images;
- There is provision for including a "Gamma correction" table;
- Raw data can be pre-processed ("filtered"), which may improve the
subsequent compression;
- Textual fields can be included, eg to contain authorship;
- ... plus other progressively more obscure features!
Things it doesn't do:
- Although large images can be divided up into a number of smaller and
more manageable data chunks, each file only ever contains one image
(so you can forget about animations ;-)
- There is no provision for "lossy" compression; it is considered that
JPEG format continues to be plenty adequate for that purpose.
Creating PNG files.
A program specifically for this is Tom Tanner's !Png2Spr, specifically
version 1.24 or higher (note that earlier versions only convert from PNG
to Sprite; the later versions are bidirectional): this was on the cover
disk of the March 1998 issue of Acorn User (not the January issue, which
was corrupt); it is also available from his website:
<http://www.argonet.co.uk/users/ttehtann/>.
The latest versions of John Kortink's !Creator can also generate PNGs.
Should I use them from now on everywhere?
Bearing in mind that it is only a comparatively recent W3C proposal,
it would be unwise to assume that ALL browsers can render PNGs; and
you wouldn't want your website-visitor to be disappointed!
But it is reasonable to guess that:
- Browsers that implement <OBJECT> can probably also render PNGs;
- Browsers that can't render PNGs, probably can't do <OBJECT> either:
so you can get round this by using <OBJECT> to contain your PNG,
with its "alternative content" referencing an ordinary GIF (or JPEG)
in a standard <IMG> tag . . . . . . keep reading!
Using a PNG inside <OBJECT>
Assume that you have created an artistic masterpiece as a PNG file
called "thing/png"; and that you also have a GIF version of the same
image as "thing/gif".
Consider the following fragment of HTML:
<OBJECT TYPE="image/png" DATA="thing.png">
<IMG SRC="thing.gif" ALT="Wot no piccy">
</OBJECT>
where both the <OBJECT> and <IMG> tags should also include the
appropriate WIDTH= and HEIGHT= attributes; and could also include any
of ALIGN= or BORDER= or HSPACE= or TITLE= or VSPACE= attributes.
Different browsers may interpret this in the following ways:
- If it supports <OBJECT> and can render PNGs, then "thing.png" will
appear, and the <IMG> and </OBJECT> tags will be skipped over;
- If it supports <OBJECT> but cannot render PNGs, then it should instead
implement the "alternative" <IMG> tag, and "thing.gif" should appear;
- If it doesn't support <OBJECT> it will ignore that tag, carry on and
"obey" the <IMG> tag to render the GIF, and ignore the </OBJECT> tag;
- If graphics have been turned off, it should drop through to the ALT
attribute and display "Wot no piccy".
(The same could be done with a JPEG instead of the GIF in the example)
John Alldred <john@protovale.co.uk> 28May98
http://www.protovale.co.uk/john/
Back to Home Page . . . . . .
Back to "Tutors" page