Skip to content

Commit 6679d4c

Browse files
committed
Merge pull request #3 from zrong/master
add pngquant to tbbl
2 parents 98a2ee2 + 53b4199 commit 6679d4c

17 files changed

+446
-17
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
setup(
3535
name="tbbl",
36-
version="0.0.3",
36+
version="0.0.7",
3737
url='http://zengrong.net/',
3838
author='zrong',
3939
author_email='[email protected]',

tbbl/admin.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def rebuildConf(self):
5555
slog.info('Regenerate "%s" done.'%confFile)
5656

5757
def src(self):
58-
srcDIR = conf.getClientPath('src')
58+
srcDIR = self.conf.getClientPath('src')
5959

6060
slog.info('Packaging lua framework to a tempfile')
6161
files = []
@@ -66,8 +66,7 @@ def src(self):
6666
continue
6767
files.append(path)
6868
pre = len(srcDIR)-3
69-
self.upload218Sim(create_zip(files, pre), 'hhlplayer/src.zip')
70-
69+
self.upload218Sim(create_zip(files, pre), self.conf.lib_conf.src)
7170

7271
def res(self):
7372
resDir = self.conf.getClientPath('res')
@@ -82,7 +81,7 @@ def res(self):
8281

8382
# len('res') == 3, it will includ 'res' prefix in zip file
8483
pre = len(resDir)-3
85-
self.upload218Sim(create_zip(files, pre), 'hhlplayer/res.zip')
84+
self.upload218Sim(create_zip(files, pre), self.conf.lib_conf.res)
8685

8786
def cocos(self):
8887
if not self.isAdmin():
@@ -140,7 +139,6 @@ def cpp(self):
140139
pre = len(runtimeDir)-len(dirname)
141140
self.upload218Lib(create_zip(files, pre), self.conf.lib_conf.cpp)
142141

143-
144142
def lua(self):
145143
if not self.isAdmin():
146144
return

tbbl/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def getPHP(self):
8888
return self.getBin('quick/win32/php.exe') if self.is_windows else 'php'
8989

9090
def getBin(self, path):
91-
return resource_filename('yhqb', 'bin/'+path)
91+
return resource_filename('tbbl', 'bin/'+path)
9292

9393
def getJinjaTempl(self, name):
9494
return self.getTemplFile(name, 'templ.jinja.%s')

tbbl/bin/pngquant/mac/COPYRIGHT

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
The quantization and dithering code in pngquant is lifted from Jef Poskanzer's
2+
'ppmquant', part of his wonderful PBMPLUS tool suite.
3+
4+
Greg Roelofs hacked it into a (in his words) "slightly cheesy" 'pamquant' back
5+
in 1997 (see http://pobox.com/~newt/greg_rgba.html) and finally he ripped out
6+
the cheesy file-I/O parts and replaced them with nice PNG code in December
7+
2000. The PNG reading and writing code is a merged and slightly simplified
8+
version of readpng, readpng2, and writepng from his book "PNG: The Definitive
9+
Guide."
10+
In 2014 Greg has relicensed the code under the simplified BSD license.
11+
12+
Note that both licenses are basically BSD-like; that is, use the code however
13+
you like, as long as you acknowledge its origins.
14+
15+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
16+
17+
pngquant.c:
18+
19+
© 1989, 1991 by Jef Poskanzer.
20+
21+
Permission to use, copy, modify, and distribute this software and its
22+
documentation for any purpose and without fee is hereby granted, provided
23+
that the above copyright notice appear in all copies and that both that
24+
copyright notice and this permission notice appear in supporting
25+
documentation. This software is provided "as is" without express or
26+
implied warranty.
27+
28+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
29+
30+
pngquant.c and rwpng.c/h:
31+
32+
© 1997-2002 by Greg Roelofs; based on an idea by Stefan Schneider.
33+
© 2009-2014 by Kornel Lesiński.
34+
35+
All rights reserved.
36+
37+
Redistribution and use in source and binary forms, with or without modification,
38+
are permitted provided that the following conditions are met:
39+
40+
1. Redistributions of source code must retain the above copyright notice,
41+
this list of conditions and the following disclaimer.
42+
43+
2. Redistributions in binary form must reproduce the above copyright notice,
44+
this list of conditions and the following disclaimer in the documentation
45+
and/or other materials provided with the distribution.
46+
47+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

tbbl/bin/pngquant/mac/README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#pngquant 2
2+
3+
This is the official `pngquant` and `libimagequant`.
4+
5+
[pngquant](http://pngquant.org) converts 24/32-bit RGBA PNGs to 8-bit palette with *alpha channel preserved*.
6+
Such images are compatible with all modern browsers, and a special compatibility setting exists which helps transparency degrade well in Internet Explorer 6.
7+
8+
Quantized files are often 40-70% smaller than their 24/32-bit version.
9+
10+
This utility works on Linux, Mac OS X and Windows.
11+
12+
##Usage
13+
14+
- batch conversion of multiple files: `pngquant *.png`
15+
- Unix-style stdin/stdout chaining: `… | pngquant - | …`
16+
17+
To further reduce file size, try [optipng](http://optipng.sourceforge.net) or [ImageOptim](http://imageoptim.pornel.net).
18+
19+
##Improvements since 1.0
20+
21+
Generated files are both smaller and look much better.
22+
23+
* Significantly better quality of quantisation
24+
25+
- more accurate remapping of semitransparent colors
26+
- special dithering algorithm that does not add noise in well-quantized areas of the image
27+
- uses variance instead of popularity for box selection (improvement suggested in the original median cut paper)
28+
- feedback loop that repeats median cut for poorly quantized colors
29+
- additional colormap improvement using Voronoi iteration
30+
- supports much larger number of colors in input images without degradation of quality
31+
- gamma correction (output is always generated with gamma 2.2 for web compatibility)
32+
33+
* More flexible commandline usage
34+
35+
- number of colors defaults to 256
36+
- long options and standard switches like `--` and `-` are allowed
37+
38+
* Refactored and modernised code
39+
40+
- C99 with no workarounds for old systems
41+
- floating-point math used throughout
42+
- Intel SSE optimisations
43+
- multicore support via OpenMP
44+
- quantization moved to standalone libimagequant
45+
46+
##Options
47+
48+
See `pngquant -h` for full list.
49+
50+
###`--quality min-max`
51+
52+
`min` and `max` are numbers in range 0 (worst) to 100 (perfect), similar to JPEG. pngquant will use the least amount of colors required to meet or exceed the `max` quality. If conversion results in quality below the `min` quality the image won't be saved (if outputting to stdin, 24-bit original will be output) and pngquant will exit with status code 99.
53+
54+
pngquant --quality=65-80 image.png
55+
56+
###`--ext new.png`
57+
58+
Set custom extension (suffix) for output filename. By default `-or8.png` or `-fs8.png` is used. If you use `--ext=.png --force` options pngquant will overwrite input files in place (use with caution).
59+
60+
###`-o out.png` or `--output out.png`
61+
62+
Writes converted file to the given path. When this option is used only single input file is allowed.
63+
64+
###`--skip-if-larger`
65+
66+
Don't write converted files if the conversion isn't worth it.
67+
68+
###`--speed N`
69+
70+
Speed/quality trade-off from 1 (brute-force) to 11 (fastest). The default is 3. Speed 10 has 5% lower quality, but is 8 times faster than the default. Speed 11 disables dithering and lowers compression level.
71+
72+
###`--nofs`
73+
74+
Disables Floyd-Steinberg dithering.
75+
76+
###`--floyd=0.5`
77+
78+
Controls level of dithering (0 = none, 1 = full).
79+
80+
###`--posterize bits`
81+
82+
Reduce precision of the palette by number of bits. Use when the image will be displayed on low-depth screens (e.g. 16-bit displays or compressed textures in ARGB444 format).
83+
84+
###`--version`
85+
86+
Print version information to stdout.
87+
88+
###`-`
89+
90+
Read image from stdin and send result to stdout.
91+
92+
###`--`
93+
94+
Stops processing of arguments. This allows use of file names that start with `-`. If you're using pngquant in a script, it's advisable to put this before file names:
95+
96+
pngquant $OPTIONS -- "$FILE"
97+

tbbl/bin/pngquant/mac/pngquant

699 KB
Binary file not shown.

tbbl/bin/pngquant/mac/pngquant-openmp

782 KB
Binary file not shown.

tbbl/bin/pngquant/mac/pngquant-ppc

47.9 KB
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@echo off
2+
3+
set path=%~d0%~p0
4+
5+
:start
6+
7+
"%path%pngquant.exe" --force --verbose --quality=45-85 %1
8+
"%path%pngquant.exe" --force --verbose --ordered --speed=1 --quality=50-90 %1
9+
10+
shift
11+
if NOT x%1==x goto start
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@echo off
2+
3+
set path=%~d0%~p0
4+
5+
:start
6+
7+
"%path%pngquant.exe" --iebug --force --verbose 256 %1
8+
"%path%pngquant.exe" --iebug --force --verbose --speed=1 --ordered 256 %1
9+
10+
shift
11+
if NOT x%1==x goto start

0 commit comments

Comments
 (0)