Commit f8b0fe79 authored by Andreas Tille's avatar Andreas Tille

New upstream version 2.8.2

parent 313ff529
*.dylib
*.mode1v3
*.o
*.lo
*.pbxproj
*.pbxuser
build
DerivedData
pngquant
lib/libimagequant.a
config.mk
test/test
[submodule "lib"]
path = lib
url = https://github.com/ImageOptim/libimagequant.git
version 2.8
-----------
- libimagequant is a separate project
- --strip option to disable copying of PNG metadata
version 2.7
-----------
- improved dithering of saturated and semitransparent colors
- fixed order of log output when using openmp
- improved quality sanity check in --skip-if-larger option
- disabled palette post-processing on colors from --map option to preserve them exactly
version 2.6
-----------
- when source image has no color profile information, the output won't have either
version 2.5
-----------
- replaced color search algorithm with vantage point tree, which is much faster and more reliable
- deprecated IE6 workaround
- warn when compiled without color profile support
- Rust API for libimagequant
version 2.4
-----------
- fixed remapping of bright colors when dithering
- added libimagequant API to add fixed preset colors to the palette
version 2.3
-----------
......
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at kornel@geekhood.net. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
Thank you for contributing! pngquant and libimagequant are licensed under multiple
licensed, so to make things clear, I'm accepting contributions as licensed under
the BSD 2-clause license:
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This diff is collapsed.
To build pngquant from source on Mac OS X and most Linux distributions,
simply run:
To get the code:
$ git clone --recursive https://github.com/pornel/pngquant.git
To build pngquant from source on macOS and most Linux distributions, run:
$ make
......
-include config.mk
BIN ?= pngquant
BINPREFIX = $(DESTDIR)$(PREFIX)/bin
BINPREFIX ?= $(DESTDIR)$(PREFIX)/bin
MANPREFIX ?= $(DESTDIR)$(PREFIX)/share/man
OBJS = pngquant.o rwpng.o
COCOA_OBJS = rwpng_cocoa.o
......@@ -11,23 +12,27 @@ OBJS += $(COCOA_OBJS)
endif
STATICLIB = lib/libimagequant.a
SHAREDLIB = lib/libimagequant.so
DISTFILES = *.[chm] pngquant.1 Makefile configure README.md INSTALL CHANGELOG COPYRIGHT
TARNAME = pngquant-$(VERSION)
TARFILE = $(TARNAME)-src.tar.bz2
TARFILE = $(TARNAME)-src.tar.gz
LIBDISTFILES = lib/*.[ch] lib/COPYRIGHT lib/MANUAL.md lib/configure lib/Makefile
LIBDISTFILES = lib/*.[ch] lib/COPYRIGHT lib/README.md lib/configure lib/Makefile
DLL=libimagequant.dll
DLLIMP=libimagequant_dll.a
DLLDEF=libimagequant_dll.def
TESTBIN = test/test
all: $(BIN)
staticlib:
staticlib: $(STATICLIB)
$(STATICLIB): config.mk $(LIBDISTFILES)
$(MAKE) -C lib static
$(STATICLIB): config.mk staticlib
sharedlib: lib/libimagequant.h
$(MAKE) -C lib shared
$(SHAREDLIB): config.mk sharedlib
$(OBJS): $(wildcard *.h) config.mk
......@@ -37,8 +42,20 @@ rwpng_cocoa.o: rwpng_cocoa.m
$(BIN): $(OBJS) $(STATICLIB)
$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@
test: $(BIN)
./test/test.sh ./test $(BIN)
$(TESTBIN): test/test.o $(STATICLIB)
$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@
test: $(BIN) $(TESTBIN)
./test/test.sh ./test $(BIN) $(TESTBIN)
bin.shared: $(OBJS) $(SHAREDLIB)
$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $(BIN)
testbin.shared: test/test.o $(SHAREDLIB)
$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $(TESTBIN)
test.shared: bin.shared testbin.shared
./test/test.sh ./test $(BIN) $(TESTBIN)
dist: $(TARFILE)
......@@ -47,16 +64,19 @@ $(TARFILE): $(DISTFILES)
mkdir -p $(TARNAME)/lib
cp $(DISTFILES) $(TARNAME)
cp $(LIBDISTFILES) $(TARNAME)/lib
tar -cjf $(TARFILE) --numeric-owner --exclude='._*' $(TARNAME)
tar -czf $(TARFILE) --numeric-owner --exclude='._*' $(TARNAME)
rm -rf $(TARNAME)
-shasum $(TARFILE)
install: $(BIN)
install: $(BIN) $(BIN).1
-mkdir -p '$(BINPREFIX)'
-mkdir -p '$(MANPREFIX)/man1'
install -m 0755 -p '$(BIN)' '$(BINPREFIX)/$(BIN)'
install -m 0644 -p '$(BIN).1' '$(MANPREFIX)/man1/'
uninstall:
rm -f '$(BINPREFIX)/$(BIN)'
rm -f '$(MANPREFIX)/man1/$(BIN).1'
clean:
$(MAKE) -C lib clean
......@@ -64,12 +84,15 @@ clean:
distclean: clean
$(MAKE) -C lib distclean
rm -f config.mk pngquant-*-src.tar.bz2
rm -f config.mk pngquant-*-src.tar.gz
config.mk:
config.mk: lib/libimagequant.h
ifeq ($(filter %clean %distclean, $(MAKECMDGOALS)), )
./configure
endif
lib/libimagequant.h:
git submodule init && git submodule update || true
.PHONY: all clean dist distclean dll install uninstall test staticlib
.DELETE_ON_ERROR:
#pngquant 2
# pngquant 2
This is the official `pngquant` and `libimagequant`.
[pngquant](https://pngquant.org) converts 24/32-bit RGBA PNGs to 8-bit palette with *alpha channel preserved*.
Such images are fully standards-compliant and are supported by all web browsers.
[pngquant](http://pngquant.org) converts 24/32-bit RGBA PNGs to 8-bit palette with *alpha channel preserved*.
Such images are compatible with all modern browsers, and a special compatibility setting exists which helps transparency degrade well in Internet Explorer 6.
Quantized files are often 60-80% smaller than their 24/32-bit versions.
Quantized files are often 40-70% smaller than their 24/32-bit version.
This utility works on Linux, Mac OS X and Windows. [This](https://github.com/pornel/pngquant) is the official `pngquant` repository.
This utility works on Linux, Mac OS X and Windows.
##Usage
## Usage
- batch conversion of multiple files: `pngquant *.png`
- Unix-style stdin/stdout chaining: `… | pngquant - | …`
To further reduce file size, try [optipng](http://optipng.sourceforge.net) or [ImageOptim](http://imageoptim.pornel.net).
To further reduce file size, try [optipng](http://optipng.sourceforge.net), [ImageOptim](https://imageoptim.com), or [zopflipng](https://github.com/google/zopfli).
##Improvements since 1.0
## Improvements since 1.0
Generated files are both smaller and look much better.
......@@ -24,74 +22,76 @@ Generated files are both smaller and look much better.
- more accurate remapping of semitransparent colors
- special dithering algorithm that does not add noise in well-quantized areas of the image
- uses variance instead of popularity for box selection (improvement suggested in the original median cut paper)
- feedback loop that repeats median cut for poorly quantized colors
- additional colormap improvement using Voronoi iteration
- supports much larger number of colors in input images without degradation of quality
- gamma correction (output is always generated with gamma 2.2 for web compatibility)
* More flexible commandline usage
- number of colors defaults to 256
- long options and standard switches like `--` and `-` are allowed
- gamma correction and optional color profile support (output is always in gamma 2.2 for web compatibility)
* Refactored and modernised code
- C99 with no workarounds for old systems
- floating-point math used throughout
- Intel SSE optimisations
- quantization [moved to standalone libimagequant](https://github.com/ImageOptim/libimagequant)
- C99 with no workarounds for legacy systems or compilers ([apart from Visual Studio](https://github.com/pornel/pngquant/tree/msvc))
- Intel SSE optimisations and floating-point math used throughout
- multicore support via OpenMP
- quantization moved to standalone libimagequant
##Options
## Options
See `pngquant -h` for full list.
###`--quality min-max`
### `--quality min-max`
`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.
pngquant --quality=65-80 image.png
###`--ext new.png`
### `--ext new.png`
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).
###`-o out.png` or `--output out.png`
### `-o out.png` or `--output out.png`
Writes converted file to the given path. When this option is used only single input file is allowed.
###`--skip-if-larger`
### `--skip-if-larger`
Don't write converted files if the conversion isn't worth it.
###`--speed N`
### `--speed N`
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.
###`--nofs`
### `--nofs`
Disables Floyd-Steinberg dithering.
###`--floyd=0.5`
### `--floyd=0.5`
Controls level of dithering (0 = none, 1 = full).
Controls level of dithering (0 = none, 1 = full). Note that the `=` character is required.
###`--posterize bits`
### `--posterize bits`
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).
###`--version`
### `--strip`
Don't copy optional PNG chunks. Metadata is always removed on Mac (when using Cocoa reader).
### `--version`
Print version information to stdout.
###`-`
### `-`
Read image from stdin and send result to stdout.
###`--`
### `--`
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:
pngquant $OPTIONS -- "$FILE"
## License
pngquant is dual-licensed:
* GPL v3 or later, and additional copyright notice must be kept for older parts of the code. See [COPYRIGHT](https://github.com/pornel/pngquant/blob/master/COPYRIGHT) for details.
* For use in non-GPL software (e.g. closed-source or App Store distribution) please ask kornel@pngquant.org for a commercial license.
......@@ -2,6 +2,12 @@
CONFIG="config.mk"
PREFIX="/usr/local"
test -f lib/libimagequant.h || { git submodule init && git submodule update; } || {
echo "error: libimagequant not found in ./lib/"
echo "If you're using git, do clone with --recursive, or download from https://github.com/ImageOptim/libimagequant"
exit 1;
}
VERSION=$(grep LIQ_VERSION_STRING lib/libimagequant.h | grep -Eo "2\.[0-9.]+")
DEBUG=
......@@ -40,8 +46,8 @@ for i in "$@"; do
help "--with-lcms2/--without-lcms2 compile with color profile support"
if [[ "$OSTYPE" =~ "darwin" ]]; then
help "--with-cocoa/--without-cocoa use Cocoa framework to read images"
help "--with-libpng=<dir> search for libpng in directory"
fi
help "--with-libpng=<dir> search for libpng in directory"
echo
help "CC=<compiler> use given compiler command"
help "CFLAGS=<flags> pass options to the compiler"
......@@ -102,8 +108,7 @@ fi
EXTRA_LDFLAGS="$EXTRA_LDFLAGS ${i#*=}"
;;
*)
echo "error: unknown switch ${i%%=*} (see $0 --help for the list)"
exit 1
echo "warning: unknown switch ${i%%=*} (see $0 --help for the list)"
;;
esac
done
......@@ -130,23 +135,23 @@ status() {
# Append to CFLAGS if compiler supports flag, with optional prerequisite.
# Fails on errors and warnings.
conditional_cflags() {
if [ -z "echo | $("$CC" -xc -S -o /dev/null $2 $1 2>&1)" ]; then
if [ -z "$(echo | "$CC" -xc -S -o /dev/null $2 $1 - 2>&1)" ]; then
cflags "$1"
fi
}
# returns first matching file in directory
find_f() {
echo $(find "$1" -not -type d -name "$2" -print -quit 2> /dev/null)
echo $(find "$1" -not -path '*/.git/*' -not -type d -name "$2" -print -quit 2> /dev/null)
}
# returns first matching file in directory (no symlinks)
find_h() {
echo $(find "$1" -type f -name "$2" -print -quit 2> /dev/null)
echo $(find "$1" -not -path '*/.*/*' -type f -name "$2" -print -quit 2> /dev/null)
}
find_pkgconfig() {
LIBNAME=$1
local LIBNAME=$1
if pkg-config --exists "$LIBNAME" &> /dev/null; then
cflags "$(pkg-config --cflags "$LIBNAME")"
lflags "$(pkg-config --libs "$LIBNAME")"
......@@ -157,13 +162,13 @@ find_pkgconfig() {
}
find_static() {
LIBNAME=$1
HEADERPATTERN=$2
STATICPATTERN=$3
local LIBNAME=$1
local HEADERPATTERN=$2
local STATICPATTERN=$3
HPATH=$(find_h . "$HEADERPATTERN")
local HPATH=$(find_h . "$HEADERPATTERN")
if [ -n "$HPATH" ]; then
APATH=$(find_f . "$STATICPATTERN")
local APATH=$(find_f . "$STATICPATTERN")
if [ -n "$APATH" ]; then
cflags "-I${HPATH%/*}"
lflags "${APATH}"
......@@ -174,12 +179,32 @@ find_static() {
return 1
}
find_dynamic() {
local LIBNAME=$1
local HEADERPATTERN=$2
local DYNAMICPATTERN=$3
local HEADERDIR=$4
local LIBDIR=$5
local HPATH=$(find_h "$HEADERDIR" "$HEADERPATTERN")
if [ -n "$HPATH" ]; then
local SOPATH=$(find_f "$LIBDIR" "$DYNAMICPATTERN")
if [ -n "$SOPATH" ]; then
cflags "-I${HPATH%/*}"
lflags "-L${SOPATH%/*} -l$DYNAMICLIBNAME"
status "$LIBNAME" "shared ... $SOPATH"
return 0
fi
fi
return 1
}
find_library() {
LIBNAME=$1
DYNAMICLIBNAME=$2
HEADERPATTERN=$3
STATICPATTERN=$4
DYNAMICPATTERN=$5
local LIBNAME=$1
local DYNAMICLIBNAME=$2
local HEADERPATTERN=$3
local STATICPATTERN=$4
local DYNAMICPATTERN=$5
# try static in current directory first
if find_static "$LIBNAME" "$HEADERPATTERN" "$STATICPATTERN"; then
......@@ -193,15 +218,8 @@ find_library() {
for i in "${DIRS[@]}"; do
DIR=($i)
HPATH=$(find_h "${DIR[0]}" "$HEADERPATTERN")
if [ -n "$HPATH" ]; then
SOPATH=$(find_f "${DIR[1]}" "$DYNAMICPATTERN")
if [ -n "$SOPATH" ]; then
cflags "-I${HPATH%/*}"
lflags "-L${SOPATH%/*} -l$DYNAMICLIBNAME"
status "$LIBNAME" "shared ... $SOPATH"
return 0
fi
if find_dynamic "$LIBNAME" "$HEADERPATTERN" "$DYNAMICPATTERN" "${DIR[0]}" "${DIR[1]}"; then
return 0
fi
done
return 1
......@@ -229,22 +247,22 @@ error() {
echo
# basic check
if ! echo "int main(){}" | "$CC" -xc -std=c99 -o /dev/null - &> /dev/null; then
if ! echo "int main(){}" | "$CC" -xc -std=c99 -o /dev/null - > /dev/null; then
error "Compiler" "$CC failed to compile anything (make sure it's installed and supports C99)"
fi
status "Compiler" "$CC"
# init flags
CFLAGS=${CFLAGS:--O3 -fno-math-errno -funroll-loops -fomit-frame-pointer -Wall}
CFLAGS=${CFLAGS:--fno-math-errno -funroll-loops -fomit-frame-pointer -Wall}
cflags "-std=c99 -I."
# DEBUG
if [ -z "$DEBUG" ]; then
cflags "-DNDEBUG"
cflags "-O3 -DNDEBUG"
status "Debug" "no"
else
cflags "-g"
cflags "-O1 -g"
status "Debug" "yes"
fi
......@@ -308,7 +326,13 @@ if [[ "$OSTYPE" =~ "darwin" ]]; then
fi
# pairs of possible *.h and lib*.so locations
DIRS=("/usr/local/include /usr/local/lib"
DIRS=()
if command -v >/dev/null libpng-config; then
DIRS+=("$(libpng-config --prefix) $(libpng-config --libdir)")
fi
DIRS+=("/usr/local/include /usr/local/lib"
"/usr/include /usr/lib"
"/opt/local/include /opt/local/lib" # macports
)
......@@ -328,16 +352,16 @@ fi
# libpng
# try if given flags are enough
SUCCESS=0
HAS_LIBPNG=0
if echo "#include \"png.h\"
int main(){
return !png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
}" | "$CC" -xc -std=c99 -o /dev/null $CFLAGS $LDFLAGS - &> /dev/null; then
status "libpng" "custom flags"
SUCCESS=1
HAS_LIBPNG=1
fi
if [ "$SUCCESS" -eq 0 ]; then
if [ "$HAS_LIBPNG" -eq 0 ]; then
# try static in the given directory
PNGH=$(find_h "$LIBPNG_DIR" "png.h")
if [ -n "$PNGH" ]; then
......@@ -349,15 +373,15 @@ if [ "$SUCCESS" -eq 0 ]; then
cflags "-I${PNGH%/*}"
lflags "${LIBPNGA}"
status "libpng" "static (${PNGH_STRING})"
SUCCESS=1
HAS_LIBPNG=1
fi
fi
fi
fi
# try shared
if [ "$SUCCESS" -eq 0 ]; then
if [ "$HAS_LIBPNG" -eq 0 ]; then
if find_pkgconfig libpng; then
SUCCESS=1
HAS_LIBPNG=1
else
for i in "${DIRS[@]}"; do
DIR=($i)
......@@ -371,7 +395,7 @@ if [ "$SUCCESS" -eq 0 ]; then
cflags "-I${PNGH%/*}"
lflags "-L${LIBPNGSO%/*} -lpng${PNGH_MAJMIN}"
status "libpng" "shared (${PNGH_STRING})"
SUCCESS=1
HAS_LIBPNG=1
break
fi
fi
......@@ -379,11 +403,11 @@ if [ "$SUCCESS" -eq 0 ]; then
done
fi
fi
if [ "$SUCCESS" -eq 0 ]; then
if [ "$HAS_LIBPNG" -eq 0 ]; then
if [[ "$OSTYPE" =~ "darwin" ]]; then
LIBPNG_CMD='`brew install libpng`'
else
LIBPNG_CMD='`apt-get install libpng-dev` or `yum install libpng-devel`'
LIBPNG_CMD='`apt-get install libpng16-dev` or `apt-get install libpng-dev` or `yum install libpng-devel`'
fi
error "libpng" "not found (try: $LIBPNG_CMD)"
fi
......@@ -445,6 +469,7 @@ CC = $CC
CFLAGS = $CFLAGS
LDFLAGS = $LDFLAGS
COCOA_READER = $COCOA_READER
SOLIBSUFFIX = $SOLIBSUFFIX
" > "$CONFIG"
# Configure static library the same way
......
© 1997-2002 by Greg Roelofs; based on an idea by Stefan Schneider.
© 2009-2015 by Kornel Lesiński.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
© 1989, 1991 by Jef Poskanzer.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation. This software is provided "as is" without express or
implied warranty.
This diff is collapsed.
-include config.mk
STATICLIB=libimagequant.a
SHAREDLIB=libimagequant.so.0
DLL=libimagequant.dll
DLLIMP=libimagequant_dll.a
DLLDEF=libimagequant_dll.def
OBJS = pam.o mediancut.o blur.o mempool.o viter.o nearest.o libimagequant.o
SHAREDOBJS = $(subst .o,.lo,$(OBJS))
BUILD_CONFIGURATION="$(CC) $(CFLAGS) $(LDFLAGS)"
DISTFILES = $(OBJS:.o=.c) *.h MANUAL.md COPYRIGHT Makefile configure
TARNAME = libimagequant-$(VERSION)
TARFILE = $(TARNAME)-src.tar.bz2
all: static shared
static: $(STATICLIB)
shared: $(SHAREDLIB)
dll:
$(MAKE) CFLAGSADD="-DLIQ_EXPORT='__declspec(dllexport)'" $(DLL)
$(DLL) $(DLLIMP): $(OBJS)
$(CC) -fPIC -shared -o $(DLL) $^ $(LDFLAGS) -Wl,--out-implib,$(DLLIMP),--output-def,$(DLLDEF)
$(STATICLIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $^
$(SHAREDOBJS):
$(CC) -fPIC $(CFLAGS) -c $(@:.lo=.c) -o $@
$(SHAREDLIB): $(SHAREDOBJS)
$(CC) -shared -o $@ $^ $(LDFLAGS)
$(OBJS): $(wildcard *.h) config.mk
dist: $(TARFILE)
$(TARFILE): $(DISTFILES)
rm -rf $(TARFILE) $(TARNAME)
mkdir $(TARNAME)
cp $(DISTFILES) $(TARNAME)
tar -cjf $(TARFILE) --numeric-owner --exclude='._*' $(TARNAME)
rm -rf $(TARNAME)
-shasum $(TARFILE)
clean:
rm -f $(OBJS) $(SHAREDOBJS) $(SHAREDLIB) $(STATICLIB) $(TARFILE) $(DLL) $(DLLIMP) $(DLLDEF)
distclean: clean
rm -f config.mk
config.mk:
ifeq ($(filter %clean %distclean, $(MAKECMDGOALS)), )
./configure
endif
.PHONY: all static shared clean dist distclean dll
.DELETE_ON_ERROR:
/*
** © 2011-2015 by Kornel Lesiński.
** All rights reserved.
** See COPYRIGHT file for full license.
*/
#include "libimagequant.h"
#include "pam.h"
#include "blur.h"
/*
Blurs image horizontally (width 2*size+1) and writes it transposed to dst (called twice gives 2d blur)
*/
static void transposing_1d_blur(unsigned char *restrict src, unsigned char *restrict dst, unsigned int width, unsigned int height, const unsigned int size)
{
assert(size > 0);