~hww3/caudium

ref: 93d5a75fba08db71b832716377276978cdd7888d caudium/tools/make-power-logos.pike -rwxr-xr-x 2.5 KiB
93d5a75fWilliam Welliver storage: method "None" was missing stop function. should fix error on shutdown 1 year, 1 month ago
                                                                                
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
#!/usr/bin/env pike

#pike 7.2

mapping sizes = ([
  "large": ({ 264, 93 }), 
  "medium": ({ 176, 62 }), 
  "small": ({ 99, 35 }), 
]);


mapping colors = ([
  "antiquewhite": (["c-antiquewhite": 1, "white-filter":0 ]),
  "blue": ([ "c-blue": 1, "white-filter": 1 ]),
  "darkblue": ([ "c-blue": 1, "white-filter": 0 ]),
  "darkgreen": (["c-green":1, "white-filter":0 ]),
  "darkpurple": ([ "c-purple": 1, "white-filter": 0 ]),
  "gold": (["c-red":1, "c-yellow":1, "white-filter":0 ]),
  "lightgold": (["c-red":1, "c-yellow":1, "white-filter":1 ]),
  "lightgray": ([ "white-filter":1 ]),
  "gray": ([ "white-filter":0 ]),
  "green": (["c-green":1, "white-filter":1 ]),
  "greenblue": ([ "c-greenblue": 1, "white-filter": 0]),
  "lightblue": ([ "c-blue": 1, "c-white": 1, "white-filter": 0 ]),
  "lightgreen": (["c-green":1, "white-filter":1 ]),
  "orange": ([ "c-orange": 1, "white-filter":0]),
  "purple": ([ "c-purple": 1, "white-filter": 1 ]),
  "red": ([ "c-red": 1, "white-filter":0]),
  "white": ([ "c-white":1 ]),
  "yellow": ([ "c-yellow":1, "white-filter":0]),
]);

void main(int argc, array argv) {
  Image.XCF.GimpImage xcf;
  string version = "1.1";
  array files = ({});
  if(argc != 2) {
    werror("Syntax: %s <power.xcf>\n", argv[0]);
    exit(1);
  }
  mkdir("out"); cd("out"); map(get_dir("."), rm); cd("../");
  string sourcedata;
  if(search(argv[1], ".bz2") != -1) {
#if constant(bzip2.inflate)
    sourcedata = bzip2.inflate()->inflate(Stdio.read_file(argv[1]));
#else
    sourcedata = Process.popen("bzip2 -d -c "+argv[1]);
#endif
  }
  xcf =  Image.XCF.__decode(sourcedata);
  string name = "out/power-%s-%s.gif";
  foreach(sort(indices(colors)), string col) {
    if(sizeof(colors[col])) {
      write(col+": ");
      foreach(xcf->layers, object layer) {
	if(!zero_type(colors[col][layer->name])) {
	  layer->flags->visible = colors[col][layer->name];
	} else if(layer->name[..1] == "c-") {
	  layer->flags->visible = 0;
	} else if(layer->name[..1] == "v-") {
	  if(layer->name[2..] == version) {
	    layer->flags->visible = 1;
	  } else {
	    layer->flags->visible = 0;
	  }
	}
      }
      Image.Image source = Image.XCF._decode(xcf)->image;
      foreach(sort(indices(sizes)), string size) {
	write(size +"...");
	Image.Image out = source->scale(@sizes[size]);
	string fn = sprintf(name, size, col);
	files += ({ fn });
	Stdio.write_file(fn, Image.GIF.encode(out));
      }
      write("done.\n");
    }
  }
  write("Running gifsicle...\n");
  object gifs = Process.create_process( ({ "gifsicle", "-O4", "-b", "-k64",
					   "-f" }) + files);
  gifs->wait();
}