1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.1.2//EN"
"docbook/docbookx.dtd">
<refentry id='sng.1'>
<refmeta>
<refentrytitle>sng</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class='source'>Open Source</refmiscinfo>
</refmeta>
<refnamediv id='name'>
<refname>sng</refname>
<refpurpose> compiler/decompiler for Scriptable Network Graphics</refpurpose>
</refnamediv>
<refsynopsisdiv id='synopsis'>
<cmdsynopsis>
<!-- sng [-ivV] [file ...] -->
<command>sng</command> <arg choice='opt'>-ivV </arg>
<arg choice='opt' rep='repeat'><replaceable>file</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1 id='description'><title>DESCRIPTION</title>
<para>The <command>sng</command> program translates between PNG
(Portable Network Graphics) format and SNG (Scriptable Network
Graphics) format. SNG is a printable and editable minilanguage for
describing PNG files. With sng, it is easy to view and edit exotic
PNG chunks not supported by graphics editors; also, since SNG is easy
to generate from scripts, sng may be useful at the end of a pipeline
that programmatically generates PNG images.</para>
<para>An SNG description consists of a series of chunk specifications in a
simple editable text format. These generally correspond one-for-one
to PNG chunks. There is one exception; the IMAGE chunk
specification is automatically translated into an IDAT chunk (doing
appropriate interlacing, compression, etcetera).</para>
<para>Given no file arguments, <command>sng</command> translates stdin
to stdout. In this mode, it checks the first character. If that
character is printable, the input stream is assumed to contain SNG;
<command>sng</command> looks for an #SNG leader and tries to translate
the file to PNG. If the character is non-printable, the input stream
is assumed to contain PNG; <command>sng</command> tries to translate
it to SNG.</para>
<para>For each file that <command>sng</command> operates on, it does
its conversion according to the file extension (.png or .sng). The
result file has the same name left of the dot as the original, but the
opposite extension and type.</para>
<para>The -V option maskes <command>sng</command> identify itself and
its version, then exit. The -i option causes IDAT chunks in a PNG to
be dumped in raw form as IDAT chanks rather than as a reassembled
IMAGE. The -v option makes <command>sng</command> report on what
files it is converting.</para> </refsect1>
<refsect1 id='sng_language_syntax'><title>SNG LANGUAGE SYNTAX</title>
<para>In general, the SNG language is token-oriented with tokens separated
by whitespace. Anywhere that whitespace may appear, a `#' comment
leader causes all characters up to the next following newline to be
ignored. The characters `:' and `;' are treated as whitespace, except
the `;' terminates a data element (see below).</para>
<para>In the syntax descriptions below, lines between {} may occur in any
order. Elements bracketed in [] are optional; a sequence bracketed by
[]* may be repeated any number of times. Elements separated by | are
alternatives. Elements separated by plus signs are an attribute set;
any sequence of one or more of those element tokens is valid.</para>
<para>The elements <byte>, <short>, <long>,
<float>, <string> are byte numeric, short-integer numeric,
long-integer numeric, float numeriliterals respectively (all
unsigned). The <slong> element is a signed long-numeric
literal. All numerics use C conventions; that is, they are decimal
unless led by 0x (hex) or 0 (octal).</para>
<para>The element <string> is any number of
doublequote-delimited character string literals. C-style escapes
(\n, \t, \b, \r or \ followed by octal or hex
digits) are interpreted. The result is the concatenation of all the
literals.</para>
<para>The element <keyword> is a doublequote-delimited PNG
keyword; that is, a string of no more than 79 printable Latin-1
characters or spaces, with no leading and no trailing and no
consecutive spaces.</para>
<para>A <data> element consists of a sequence of byte
specifications in any of the following formats. Either '}' or ';' ends
a data literal; `}' also ends the enclosing chunk.</para>
<para>1. <emphasis remap='B'>string</emphasis> format is an SNG string
literal or sequence of string literals (see above). The bytes of data
are the string contents.</para>
<para>2. <emphasis remap='B'>base64</emphasis> format is signaled by
the leading token `base64'. It is RFC2045 base-64 encoding, with
decimal digits representing values 0-9, followed by A-Z for 10-35,
followed by a-z for 36-61, followed by + for 62 and / for 63. Base64
format can be used if the image either has total (color plus alpha)
bit depth of four or less, or it is a spaletted image with 64 or fewer
colors. Whitespace is ignored.</para>
<para>3. <emphasis remap='B'>hex</emphasis> format is signaled by the
leading token `hex'. In hex format, each byte is specified by two hex
digits (0123456789abcdef), most significant first. Whitespace is
ignored.</para>
<para>4. <emphasis remap='B'>P1</emphasis> format is Portable Bit Map
(PBM) format P1. A decimal height and width follow; it is a fatal
error for them to fail to match the IHDR dimensions. Following this,
the only non-whitespace charaters are expected to be `0' and `1', with
the obvious values. Whitespace is ignored.</para>
<para>5. <emphasis remap='B'>P3</emphasis> format is Portable Pixel
Map (PPM) format P3. A decimal height and width follow; it is a fatal
error for them to fail to match the IHDR dimensions. A maximum
channel value in decimal follows; it is a fatal error for any
following channel value to exceed this value. Following this are
triples of decimal channel values representing RGB triples.
Whitespace separates decimal channel values but is otherwise
ignored.</para>
<para>An <rgb> element may be expanded to:</para>
<literallayout remap='.nf'>
(<byte>, <byte>, <byte>) | <string>
</literallayout> <!-- .fi -->
<para>That is, it is either a paren-enclosed list of RGB values or a string
naming a color named in the X RGB database. Note that color names are
not necessarily portable between hosts or even displays, due to
different screen gammas and colorimetric biases. For this
reason, the SNG decompiler generates color names in comments.</para>
<para>IMAGE segments contain unpacked and uninterlaced raster data. There
will be exactly one IMAGE per SNG dump, containing the pixel data from
all IDAT chunks, unless the -i option is on. In that case, there will
be multiple IDAT chunks containing raw (compressed) image data.</para>
<para>The options member of an IMAGE chunk (if present) sets image write
transformations, supplying the third argument of the png_write_png()
call used for output. Note that for images with a bit depth of less
than 8, there is a default `packing' transformation. Consult the
libpng(3) manual page for details.</para>
<para>Every SNG file must begin with the string "#SNG", followed by optional
SNG version information, followed by a colon (`:', ASCII 58)
character. The remainder of the first line is ignored by SNG.</para>
<para>Comments in the syntax diagram describe intended semantics. This
specification should be read in conjunction with the PNG standard.</para>
<literallayout remap='.nf'>
IHDR {
height <long>
width <long>
bitdepth <byte>
[using grayscale+color+palette+alpha]
[with interlace] # Adam7 assumed if interlacing on
}
PLTE {
[<rgb>]* # RGB triples or X color names
}
IDAT {
<data>
}
gAMA {<float>}
cHRM {
white (<float>,<float>) # White point x and y
red (<float>,<float>)
green (<float>,<float>)
blue (<float>,<float>)
}
sRGB {<byte>} # Colorimetry intent, range 0-3
iCCP { # International Color Consortium profile
name <keyword>
profile <data>
}
sBIT {
red <byte> # Color images only
blue <byte> # Color images only
green <byte> # Color images only
gray <byte> # Grayscale images only
alpha <byte> # Images with alpha only
}
bKGD {
red <short> # Color images only
blue <short> # Color images only
green <short> # Color images only
gray <short> # Grayscale images only
index <byte> # Paletted images only
}
hIST {
<short> [, <short>]* # Count must match palette size
}
tRNS {
[gray <short>] # Grayscale images only
[red <short>] # True-color images only
[green <short>] # True-color images only
[blue <short>] # True-color images only
[<byte>]* # Paletted images only
}
pHYs {
xpixels <long>
ypixels <long>
[per meter]
}
tIME {
year <short>
month <byte>
day <byte>
hour <byte>
minute <byte>
second <byte>
}
tEXt { # Ordinary text chunk
keyword <keyword>
text <string>
}
zTXt { # Compressed text chunk
keyword <keyword>
text <string>
}
iTXt { # International UTF-8 keyword
language <keyword>
keyword <keyword>
translated <keyword> # Translation of the keyword
text <string>
[compressed]
}
oFFs {
xoffset <slong>
yoffset <slong>
[unit pixels|micrometers]*
}
sPLT {
name <keyword>
depth <byte>
[<rgb>, <short>, <short>]* # Color followed by alpha and frequency
}
pCAL {
name <keyword>
x0 <slong>
x1 <slong>
mapping linear|euler|exponential|hyperboli unit <string>
[parameters <string>]
}
sCAL {
unit meter|radian
width <string>
height <string>
}
IMAGE {
options identity+packing+packswap+invert_mono
+shift+bgr+swap_alpha+invert_alpha+swap_endian+strip_filler
pixels <data>
}
gIFg {
disposal <byte>
input <byte>
delay <short>
}
gIFx {
identifier <string> # Must be 8 characters
code <string> # Must be 3 characters
data <data>
}
private <string> { # Private chunk declaration
<data>
}
</literallayout> <!-- .fi -->
</refsect1>
<refsect1 id='bugs'><title>BUGS</title>
<para>The -i option doesn't work yet, and won't until libpng's ability to
suppress special handling of IDATs is working. See the
distribution TODO file for other minor problems.</para>
</refsect1>
<refsect1 id='files'><title>FILES</title>
<variablelist remap='TP'>
<varlistentry>
<term>rgb.txt</term>
<listitem>
<para>The X colorname database, used for RGB-to-name mappings in the
decompiler and name-to-RGB mappings in the compiler. </para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id='see_also'><title>SEE ALSO</title>
<para>
<citerefentry><refentrytitle>pbm</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>ppm</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
</para>
</refsect1>
<refsect1 id='author'><title>AUTHOR</title>
<para>Eric S. Raymond <email>esr@snark.thyrsus.com</email> December 1999.
The SNG home page is at <ulink url='http://sng.sourceforge.net/'>http://sng.sourceforge.net/</ulink>.</para>
<para>For more information about PNG, see the
PNG website at <<ulink url='http://www.libpng.org/pub/png/'>http://www.libpng.org/pub/png/</ulink>>.</para>
<para>The W3C recommendation is
<ulink
url="http://www.w3.org/TR/2003/PR-PNG-20030520/index-noobject.html">
Portable Network Graphics (PNG) Specification (Second
Edition)</ulink>. The PNG specification is also ISO/IEC 15948.</para>
</refsect1>
</refentry>
|