-
Notifications
You must be signed in to change notification settings - Fork 1
/
pngcam-render
executable file
·94 lines (70 loc) · 2.24 KB
/
pngcam-render
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
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use Pngcam::Render;
my $width;
my $height;
my $border = 32; # px
my $bottom;
my $png;
my $rgb;
my $quiet;
GetOptions(
'border=f' => \$border,
'width=f' => \$width,
'height=f' => \$height,
'bottom' => \$bottom,
'png=s' => \$png,
'rgb' => \$rgb,
'quiet' => \$quiet,
'help' => sub { help() },
'usage' => sub { help() },
) or help();
help() if @ARGV != 1;
my $stl_file = shift @ARGV;
$png ||= "$stl_file.png";
$width = 400 if !defined $width && !defined $height;
my $render = Pngcam::Render->new(
stl_file => $stl_file,
border => $border,
width => $width,
height => $height,
bottom => $bottom,
rgb => $rgb,
quiet => $quiet,
);
$render->run;
$render->save($png);
sub help {
print qq{Usage: pngcam-render [options] STLFILE
This program will read in the STLFILE and render it to a heightmap.
Options:
--border PX
Draw a border around the part.
Default: 32
--width PX
Set the width of the part in pixels. If height is not specified, height will be calculated
automatically to maintain aspect ratio. If neither are specified, width=400px is assumed.
The output image will be this wide, plus a border on both sides.
Default: 400
--height PX
Set the height of the part in pixels. If width is not specified, width will be calculated
automatically to maintain aspect ratio. If neither are specified, width=400px is assumed.
The output image will be this talg, plus a border on both sides.
Default: N/A
--bottom
View from the bottom, as if the part were rotated through 180 degrees around the Y axis.
Default: viewed from the top
--png PNGFILE
Set the name of the output file. If none is give, this will just be the STL file with ".png" appended.
Default: STLFILE.png
--rgb
Use R,G,B channels independently to get 24 bits of height data instead of 8.
Default: greyscale
--quiet
Suppress output of dimensions, resolutions, and progress.
Pngcam-render is a program by James Stanley. You can email me at james\@incoherency.co.uk or read my blog at https://incoherency.co.uk/
};
exit 0;
}