Gerb2tiff User Manual
Version 1.2 Last updated 6-Feb-2011
Copyright (c) 2009, 2010, 2011 Adam Seychell
This program is free software;
you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation. This
program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
The latest version of gerb2tiff is available for download at my home page
Introduction
Gerb2tiff
is a command line utility to generate a raster graphics bitmap
from
Gerber RS274X files.
The
purpose of this program is to convert Gerber RS274X files (produced
from electronic CAD software) into a bitmap image. The image
can then
be manipulated and/or printed by common graphics software to suit the
users
needs. Gerb2tiff is a simple, and fast tool, capable of
generating large high resolution images typically required for
PCB artworks.
Image Bitmap The
bitmap file produced by gerb2tiff is a compressed monochrome
TIFF.
Usage
gerb2tiff
[OPTIONS] [file1] [file2]...
Where file1 file2...
are optional gerber files rendered as overlays to a single bitmap. Each
overlay is rendered in the order specified. No modification is
made to coordinate offsets when rendering multiple overlays. Standard
input is read if no gerber files specified and --output is specified.
If
successful, a TIFF output file will be generated
containing the
rasterized image of the Gerber data.
Command
Line Options
-p,
--dpi=X |
Specifies
X dots per inch to render the bitmap. The value must be above
or equal to 1. Floating point vales are allowed. Default is
2400.
|
-o,
--output=FILE |
Set name of output TIFF to FILE. If gerber-file is specified then default is <file1>.tiff This option is required when no gerber-file specified and to allow reading from standard input.
|
-q,
--quiet | Suppress warnings and non critical messages. This option is disabled with -v option
|
-n,
--negative |
Negate
image in polarity. Images of positive polarity are plotted with black
pixels on a clear background. The image polarity is affected
by both
this option and the optional IP (Image Polarity) parameter specified in
the Gerber data. Image
polarity will be
negative if exactly one of either the Gerber IPNEG parameter is
specified or this option is specified, otherwise the image polarity
will be positive. The
result of last IP parameter to occur in the first gerber file (if
specified) or in the standard input will be used. All other occurrences
of the IP parameter will be ignored. |
b, --boarder-mm=X |
Increase
the boarder of all four sides of the image by X millimeters. The image size without any boarder is equal to the
far extremes of plotted shapes specified in the RS-274X file plus a 0
or 1 pixel boarder. Default value is 0.
|
--boarder-pixels=X | Same as
--boarder-mm except X represents boarder size in pixels. |
-t |
Parses
the Gerber input file(s) without creating any bitmap.
Useful determining image data when used in conjunction
with
-v option.
|
-v |
Verbose
mode. Display extra information while processing. Multiple -v increases
verbosity. This option also disables --quiet
|
--scale-x=S |
Scale
image in X axis by S. Negative values mirror image about the Y axis. |
--scale-y=S |
Scale
image in Y axis by S. Negative values mirror image about the X axis.
|
--grow-mm=X |
Expand
perimeter of all aperture shape features by X
millimeters. Negative values
shrink. Note tthis feature is not implimented on some dimentions of the
more complex macro apertures and to dimentions of G36 polygon
drawing.
|
--grow-pixels=X | Same as --grow-mm except X represents grow size in pixels.
| --strip-rows=N | Specifies
N rows
per strip in TIFF output. Limiting the strip size may be
required by some software when handling very large images. A small
strip size will produced slightly larger files. Please note that
gerb2tiff uses an internal working buffer equal
to the strip size and therefore memory usage will be proportional to
N. If N is zero or N is greater than the image height then the rows per
strip is equal to the image height resulting in a single strip TIFF. Default value of N is 512. |
-a,
--area |
Show
total area in units centimeters squared of both image positive
area and negative area.
Positive area is calculated from the sum of black (dark) pixels in
bitmap multiplied by the centimeter square
area occupied by one pixel. Negative area is calculated using using
white (clear) pixels instead of black (dark). Due to rounding errors,
the result will vary
slightly with DPI settings. Total area may be useful for electroplating
processes. |
--help |
Show help
screen, including version number. |
Unsupported
features of the standard
From gerb2tiff version 1.0, most the standard has been implemented,
except
for some rarely used features. Below is a list of unsupported
commands and know problems. Some of the missing features may not be
difficult for me to add and
I could be willing to implement them on request from users. The table
below lists RS-274X parameters and commands that will cause gerb2tiff
to abort with an error.
Parameter
|
Description
|
Action | Comment
|
AS
|
Axis Swap |
abort | possibly
difficult to implement |
RO
|
Rotate |
abort | inadequate
definition in standard
|
IJ
|
Image Justify |
abort | possibly
easily to implement |
KO
|
Knockout |
abort | possibly
difficult to implement
|
SR
|
Step Repeat |
ignore | possibly
difficult to implement.
|
Command
|
Description
|
Comment
|
G10
|
Linear X 10 interpolation |
inadequate
definition in standard |
G11
|
Linear X 0.1 interpolation |
inadequate
definition in standard |
G12
|
Linear X 0.01 interpolation |
inadequate
definition in standard |
Known problems:
- Although the RS-274X standard does not
exclude any of the
standard C, R, O or P apertures from being used for drawing either arc
or lines, it seems impractical implement such obscure use of the P and
O polygons. Linear line drawing is limited to standard R or C apertures
and arc drawing is limited to standard C apertures. I believe this
limitation should satisfy virtually all Gerber files in
existence.
- Polygons with self intersecting boundaries are not
automatically
corrected and will be draw unmodified.
- The standard allows circular or rectangle holes to be
defined
inside any of the Round, Rectangle, Orbround or Polygon type apertures.
Gerb2tiff will render these holes as a cleared shape and will
therefore blank out any preexisting image inside this
area.
Incompleteness of the RS-274-X standard
In
doing this project I came to realize official the RS-274X (revision
D) standard published fails to properly describe all features of Gerber
files. In particular, several ambiguities exists in aperture
descriptions that make implementation of the standard a bit of
guess work. This would explain why no two CAD software tools produce
identical outputs. The industry has gotten around the problem mainly
by avoiding the use of obscure commands and rarely used features.
Performance
Since version 1.0, gerb2tiff will process Gerber files by
dividing the bitmap into strips and rendering each strip
separately. This method greatly lowers system requirements since the
whole bitmap no longer needs to be allocated in memory. Shown
below are benchmark
test results of two example
Gerber files distributed with gerb2tiff package.
Benchmark Test Results
System:
Processor: AMD
Athlon 64 X2 2.0GHz core
OS:
Windows XP 32bit
Compiler:
gcc version 3.4.5 (mingw-vista
special r3), -O2
File
name |
Polygon
primitives |
DPI |
Image
Area
(mm) |
Bitmap
Size
(pixels) |
Process
Memory
(MB) |
Time
(seconds) |
Erik_2.gbr |
56896 |
5000 |
427
x 579 |
84133
x 114133 |
16 |
13.4 |
Erik_2.gbr |
56900 |
16000 |
427
x 579 |
269223
x 365223 |
27 |
56.9 |
PR422-0.2.gtl
|
12486 |
2400 |
85
x 64 |
8051
x 6063 |
4.0 |
1.2 |
PR422-0.2.gtl
|
12486 |
1200 |
85
x 64 |
8051
x 6063 |
3.7 |
0.9 |
|