New Upstream Release - pngquant
Ready changes
Summary
Merged new upstream version: 3.0.1 (was: 2.17.0).
Diff
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 46deb95..7c8fba5 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -2,9 +2,9 @@ name: CI
on:
push:
- branches: [ master ]
+ branches: [ main ]
pull_request:
- branches: [ master ]
+ branches: [ main ]
env:
CARGO_TERM_COLOR: always
diff --git a/CHANGELOG b/CHANGELOG
index 76055db..b96fd02 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,17 @@
+version 3.0
+-----------
+ - replaced C libimagequant library with a Rust imagequant crate
+ - switched build system from make to Cargo
+
+version 2.17
+------------
+ - fixed Unicode filenames on Windows
+ - builds for ARM
+ - small quality improvements
+
version 2.16
------------
-- reduced stack usage, prevenitng stack overlfow in pathological cases
+ - reduced stack usage, prevenitng stack overlfow in pathological cases
version 2.13-2.15
------------
diff --git a/Cargo.toml b/Cargo.toml
index 7b07039..84faf55 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,64 +1,57 @@
[package]
-version = "2.17.0"
+name = "pngquant"
+version = "3.0.1"
authors = ["Kornel Lesiński <kornel@pngquant.org>"]
+description = "Convert 24/32-bit PNG images to efficient 8-bit format with alpha channel"
build = "rust/build.rs"
categories = ["multimedia::images"]
-description = "Convert 24/32-bit images to 8-bit palette with alpha channel.\nBindings for libimagequant that powers pngquant lossy PNG compressor.\n\nDual-licensed like pngquant. See https://pngquant.org for details."
-documentation= "https://github.com/kornelski/pngquant#readme"
homepage = "https://pngquant.org"
+documentation = "https://github.com/kornelski/pngquant#readme"
include = ["/rwpng*.[ch]", "/pngquant.c","/pngquant_opts.[ch]", "/rust/*.rs", "/COPYRIGHT", "/Cargo.toml", "/README.md"]
keywords = ["quantization", "palette", "image", "pngquant", "compression"]
-license = "GPL-3.0+"
-name = "pngquant"
+license = "GPL-3.0-or-later"
readme = "README.md"
repository = "https://github.com/kornelski/pngquant.git"
-edition = "2018"
+edition = "2021"
+rust-version = "1.60"
[[bin]]
name = "pngquant"
path = "rust/bin.rs"
[build-dependencies]
-cc = "1.0.71"
+cc = "1.0.72"
dunce = "1.0.2"
[dependencies]
getopts = "0.2.21"
-libc = "0.2.106"
+libc = "0.2.112"
libpng-sys = "1.1.8"
wild = "2.0.4"
+imagequant-sys = { version = "4", path = "lib/imagequant-sys" }
[dependencies.cocoa_image]
optional = true
version = "1.0.4"
-[dependencies.imagequant-sys]
-path = "lib"
-version = "3.0.2"
-
[dependencies.lcms2-sys]
optional = true
-version = "3.1.9"
-
-[dependencies.openmp-sys]
-optional = true
-version = "1.2.0"
+version = "4.0.0"
[features]
-cocoa = ["cocoa_image"]
-default = ["sse", "lcms2"]
-lcms2 = ["lcms2-sys"]
-lcms2-static = ["lcms2", "lcms2-sys/static"]
-openmp = ["openmp-sys", "imagequant-sys/openmp"]
-openmp-static = ["openmp", "openmp-sys/static", "imagequant-sys/openmp-static"]
+cocoa = ["dep:cocoa_image"]
+default = ["lcms2"]
+lcms2 = ["dep:lcms2-sys"]
+lcms2-static = ["lcms2", "lcms2-sys?/static"]
png-static = ["libpng-sys/static"]
z-static = ["libpng-sys/static-libz"]
-static = ["lcms2-static", "png-static", "openmp-static"]
-sse = ["imagequant-sys/sse"]
-alloc_system = []
+static = ["lcms2-static", "png-static"]
[profile.release]
+opt-level = 3
+codegen-units = 1
lto = true
+panic = "abort"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
diff --git a/INSTALL b/INSTALL
index 781ff7b..ee631b2 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,49 +1,17 @@
-## Compiling on Linux, *BSD and macOS using GNU/Make
+## Compiling via Rust/Cargo
-(For instructions for Windows or Rust, see sections below.)
-
-To get the code:
-
- git clone --recursive https://github.com/kornelski/pngquant.git
-
-You will need libpng installed with development headers.
-On Linux install `libpng-dev` package. On macOS `brew install libpng`.
-
-There's an optional `./configure` step (see sections below). Run:
-
- make
-
-It will create `pngquant` executable in the current directory. If you'd like
-to install it system-wide:
-
- sudo make install
-
-By default it will be installed in `/usr/local/bin`. To install it in another
-directory run `./configure --prefix=dir && make`.
-
-pngquant uses GNU Makefile. To compile on FreeBSD you will need to use `gmake`.
-
-Avoid Linux distros that ship with libpng 1.2. It is old and buggy.
-libpng 1.6 or later is required.
-
-### Custom static libpng
-
-Extract libpng source code as a *sub*directory of pngquant source directory.
-Build static libpng (`./configure --enable-static && make`), and then
-`./configure && make` pngquant.
-
-## Compiling via Rust/Cargo (all platforms, including Windows)
+The old `configure && make` method is no longer supported.
### Prerequisites
-Install Rust 1.36 or later: https://www.rust-lang.org/install.html
+Install Rust 1.60 or later: https://rustup.rs
On Windows also install msys-git and Visual C++ Build Tools
-with Windows 8 SDK enabled, and reboot.
+with Windows 8/10/11 SDK enabled, and reboot.
### Building
-Get the code:
+Get the code by cloning *recursively*:
# Unix version
git clone --recursive https://github.com/kornelski/pngquant.git
@@ -60,24 +28,13 @@ This will create executable in `target/release/pngquant`(`.exe`).
You can build with additional features:
- cargo build --release --features=sse,lcms2
+ cargo build --release --features=lcms2
The features are:
- * `sse` — enable use of SSE on x86 CPUs.
* `lcms2` — compile with support for color profiles via Little CMS.
* `lcms2-static` — same, but link statically.
* `cocoa` — compile with support for color profiles via macOS Cocoa.
- * `openmp` — use OpenMP to accelerate conversion. Requires GCC 9 or later.
- Warning: GCC 4 will produce buggy code!
- * `openmp-static` — same, but link statically.
-
-## Compilation with OpenMP
-
- cargo build --release --features=openmp # or
- cargo build --release --features=openmp-static
-
-On macOS you may need to install gcc (`brew install gcc`) and run `export CC=gcc-10` first.
## Compilation with Cocoa image reader
@@ -95,9 +52,9 @@ Otherwise uses static build as a fallback.
Set `export LCMS2_STATIC=1` or build `--features=lcms2-static` to force static linking.
-## Compilation of `libimagequant.a` only
+## Compilation of `libimagequant_sys.a` only
If you want to use pngquant's conversion algorithm without loading/saving PNG
-files, then you can run `make` or `cargo build --release` in the `lib/` directory.
+files, then you can run `cargo build --release` in the `lib/` directory.
-The library doesn't need libpng nor zlib.
+The imagequant library doesn't need libpng nor zlib.
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 0ed12d1..0000000
--- a/Makefile
+++ /dev/null
@@ -1,80 +0,0 @@
--include config.mk
-
-LIQSRCDIR ?= lib
-BIN ?= pngquant
-BINPREFIX ?= $(DESTDIR)$(PREFIX)/bin
-MANPREFIX ?= $(DESTDIR)$(PREFIX)/share/man
-
-OBJS = pngquant.o pngquant_opts.o rwpng.o
-
-STATICLIB = $(LIQSRCDIR)/libimagequant.a
-DISTFILES = *.[chm] pngquant.1 Makefile configure README.md INSTALL CHANGELOG COPYRIGHT Cargo.toml
-TARNAME = pngquant-$(VERSION)
-TARFILE = $(TARNAME)-src.tar.gz
-
-LIBDISTFILES = $(LIQSRCDIR)/*.[ch] $(LIQSRCDIR)/COPYRIGHT $(LIQSRCDIR)/README.md $(LIQSRCDIR)/configure $(LIQSRCDIR)/Makefile $(LIQSRCDIR)/Cargo.toml
-
-TESTBIN = test/test
-
-all: $(BIN)
-
-$(LIQSRCDIR)/config.mk: config.mk
- ( cd '$(LIQSRCDIR)'; ./configure $(LIQCONFIGUREFLAGS) )
-
-$(STATICLIB): $(LIQSRCDIR)/config.mk $(LIBDISTFILES)
- $(MAKE) -C '$(LIQSRCDIR)' static
-
-$(OBJS): $(wildcard *.h) config.mk
-
-$(BIN): $(OBJS) $(STATICLIBDEPS)
- $(CC) $(OBJS) $(CFLAGS) $(LDFLAGS) -o $@
-
-$(TESTBIN): test/test.o $(STATICLIBDEPS)
- $(CC) test/test.o $(CFLAGS) $(LDFLAGS) -o $@
-
-test: $(BIN) $(TESTBIN)
- LD_LIBRARY_PATH='$(LIQSRCDIR)' ./test/test.sh ./test $(BIN) $(TESTBIN)
-
-dist: $(TARFILE)
-
-$(TARFILE): $(DISTFILES)
- test -n "$(VERSION)"
- make -C $(LIQSRCDIR) cargo
- rm -rf $(TARFILE) $(TARNAME)
- mkdir -p $(TARNAME)/lib/rust $(TARNAME)/lib/msvc-dist $(TARNAME)/rust $(TARNAME)/test/img
- cp $(DISTFILES) $(TARNAME)
- cp rust/*.rs $(TARNAME)/rust/
- cp $(LIBDISTFILES) $(TARNAME)/lib
- cp $(LIQSRCDIR)/rust-sys/*.rs $(TARNAME)/lib/rust/
- cp $(LIQSRCDIR)/msvc-dist/*.[ch] $(TARNAME)/lib/msvc-dist/
- cp test/test.c test/test.sh $(TARNAME)/test/
- cp test/img/*.png $(TARNAME)/test/img/
- find $(TARNAME) -type f | rev | sort | rev | tar -czf $(TARFILE) --numeric-owner --exclude='._*' --files-from=-
- rm -rf $(TARNAME)
- -shasum $(TARFILE)
-
-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:
- -test -n '$(LIQSRCDIR)' && $(MAKE) -C '$(LIQSRCDIR)' clean
- rm -f '$(BIN)' $(OBJS) $(TARFILE)
-
-distclean: clean
- -test -n '$(LIQSRCDIR)' && $(MAKE) -C '$(LIQSRCDIR)' distclean
- rm -f config.mk pngquant-*-src.tar.gz
-
-config.mk: Makefile
-ifeq ($(filter %clean %distclean, $(MAKECMDGOALS)), )
- ./configure
-endif
-
-.PHONY: all clean dist distclean dll install uninstall test
-.DELETE_ON_ERROR:
diff --git a/README.md b/README.md
index bbc7691..3b57cad 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@
- batch conversion of multiple files: `pngquant *.png`
- Unix-style stdin/stdout chaining: `… | pngquant - | …`
-To further reduce file size, try [optipng](http://optipng.sourceforge.net), [ImageOptim](https://imageoptim.com), or [zopflipng](https://github.com/google/zopfli).
+To further reduce file size, try [oxipng](https://lib.rs/oxipng), [ImageOptim](https://imageoptim.com), or [zopflipng](https://github.com/google/zopfli).
## Features
diff --git a/configure b/configure
deleted file mode 100755
index 66aac8c..0000000
--- a/configure
+++ /dev/null
@@ -1,547 +0,0 @@
-#!/usr/bin/env bash
-
-CONFIG="config.mk"
-PREFIX="/usr/local"
-
-DEBUG=
-LIQSRCDIR=./lib
-LIQCONFIGURE=(--quiet)
-SSE=auto
-OPENMP=
-LIBPNG_DIR=.
-LCMS2=auto
-EXTRA_CFLAGS=
-EXTRA_LDFLAGS=
-
-# make gcc default compiler unless CC is already set
-CC=${CC:-gcc}
-SKIP_CC_CHECK=0
-
-help() {
- printf "%4s %s\n" "" "$1"
-}
-
-for i in "$@"; do
- case $i in
- --help|-h)
- echo
- help "--prefix=<dir> installation directory [$PREFIX]"
- help "--extra-cflags=<flags> append to CFLAGS"
- help "--extra-ldflags=<flags> append to LDFLAGS"
- echo
- help "--enable-debug"
- help "--enable-sse/--disable-sse enable/disable SSE instructions"
- echo
- help "--with-libimagequant=<dir> external libimagequant (lib/ default)"
- help "--with-openmp=static compile with multicore support"
- 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"
-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"
- help "LDFLAGS=<flags> pass options to the linker"
- echo
- exit 0
- ;;
- # Can be set before or after configure. Latter overrides former.
- CC=*)
- CC=${i#*=}
- SKIP_CC_CHECK=1
- LIQCONFIGURE+=("$i")
- ;;
- CFLAGS=*)
- CFLAGS=${i#*=}
- LIQCONFIGURE+=("$i")
- ;;
- LDFLAGS=*)
- LDFLAGS=${i#*=}
- LIQCONFIGURE+=("$i")
- ;;
- --enable-debug)
- DEBUG=1
- LIQCONFIGURE+=("$i")
- ;;
- --enable-sse)
- SSE=1
- LIQCONFIGURE+=("$i")
- ;;
- --disable-sse)
- SSE=0
- LIQCONFIGURE+=("$i")
- ;;
- --with-openmp)
- OPENMP=1
- LIQCONFIGURE+=("$i")
- ;;
- --with-openmp=static)
- OPENMP=static
- LIQCONFIGURE+=("$i")
- ;;
- --with-lcms2)
- LCMS2=1
- ;;
- --without-lcms2)
- LCMS2=0
- ;;
- --with-cocoa)
- LCMS2=auto
- ;;
- --without-cocoa)
- LCMS2=auto
- ;;
- --with-libpng=*)
- LIBPNG_DIR=${i#*=}
- ;;
- --with-libimagequant=*)
- LIQSRCDIR=${i#*=}
- ;;
- --with-libimagequant)
- LIQSRCDIR=""
- ;;
- --prefix=*)
- PREFIX=${i#*=}
- LIQCONFIGURE+=("$i")
- ;;
- # can be used multiple times or in quotes to set multiple flags
- --extra-cflags=*)
- EXTRA_CFLAGS="$EXTRA_CFLAGS ${i#*=}"
- LIQCONFIGURE+=("$i")
- ;;
- --extra-ldflags=*)
- EXTRA_LDFLAGS="$EXTRA_LDFLAGS ${i#*=}"
- LIQCONFIGURE+=("$i")
- ;;
- *)
- echo "warning: unknown switch ${i%%=*} (see $0 --help for the list)"
- ;;
- esac
-done
-
-# If someone runs sudo make install as very first command, and configure later,
-# $CONFIG cannot be overwritten, and must be deleted before continuing.
-if [[ -f "$CONFIG" && ! -w "$CONFIG" ]]; then
- echo "Cannot overwrite file $CONFIG! Please delete it."
- exit 1
-fi
-
-cflags() {
- CFLAGS="$CFLAGS $1"
-}
-
-lflags() {
- LDFLAGS="$LDFLAGS $1"
-}
-
-status() {
- printf "%10s: %s\n" "$1" "$2"
-}
-
-# 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
- cflags "$1"
- fi
-}
-
-# returns first matching file in directory
-find_f() {
- 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" -not -path '*/.*/*' -type f -name "$2" -print -quit 2> /dev/null)
-}
-
-find_pkgconfig() {
- local LIBNAME=$1
- PKG_CONFIG=${PKG_CONFIG:-pkg-config}
- if $PKG_CONFIG --exists "$LIBNAME" &> /dev/null; then
- cflags "$($PKG_CONFIG --cflags "$LIBNAME")"
- lflags "$($PKG_CONFIG --libs "$LIBNAME")"
- LIBRARY_FOUND_VERSION=$($PKG_CONFIG --modversion "$LIBNAME")
- status "$LIBNAME" "shared ($LIBRARY_FOUND_VERSION)"
- return 0
- fi
- if ! type "$PKG_CONFIG" &> /dev/null; then
- echo "warning: pkg-config is not installed, can't search for libraries. Please install pkg-config."
- fi
- return 1
-}
-
-find_static() {
- local LIBNAME=$1
- local HEADERPATTERN=$2
- local STATICPATTERN=$3
-
- local HPATH=$(find_h . "$HEADERPATTERN")
- if [ -n "$HPATH" ]; then
- local APATH=$(find_f . "$STATICPATTERN")
- if [ -n "$APATH" ]; then
- LIBRARY_FOUND_HEADER=$HPATH
- cflags "-I${HPATH%/*}"
- lflags "${APATH}"
- status "$LIBNAME" "static ($APATH)"
- return 0
- fi
- fi
- 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
- LIBRARY_FOUND_HEADER=$HPATH
- cflags "-I${HPATH%/*}"
- lflags "-L${SOPATH%/*} -l$DYNAMICLIBNAME"
- status "$LIBNAME" "shared ... $SOPATH"
- return 0
- fi
- fi
- return 1
-}
-
-find_library() {
- local LIBNAME=$1
- local DYNAMICLIBNAME=$2
- local HEADERPATTERN=$3
- local STATICPATTERN=$4
- local DYNAMICPATTERN=$5
-
- # other functions will overwrite it
- LIBRARY_FOUND_HEADER=
- LIBRARY_FOUND_VERSION=
- LIBRARY_FOUND_BUILD=
-
- if [ "imagequant" = "$LIBNAME" -a -n "$LIQSRCDIR" -a -f "$LIQSRCDIR"/"$HEADERPATTERN" ]; then
- status "$LIBNAME" "build static"
- cflags "-I$LIQSRCDIR"
- lflags "$LIQSRCDIR/libimagequant.a"
- LIBRARY_FOUND_HEADER="$LIQSRCDIR"/"$HEADERPATTERN"
- LIBRARY_FOUND_BUILD="$LIQSRCDIR"
- return 0;
- fi
-
- # try static in current directory first
- if find_static "$LIBNAME" "$HEADERPATTERN" "$STATICPATTERN"; then
- return 0;
- fi
-
- # try shared
- if find_pkgconfig "$LIBNAME"; then
- return 0
- fi
-
- for i in "${DIRS[@]}"; do
- DIR=($i)
- if find_dynamic "$LIBNAME" "$HEADERPATTERN" "$DYNAMICPATTERN" "${DIR[0]}" "${DIR[1]}"; then
- return 0
- fi
- done
- return 1
-}
-
-# returns full png.h version string
-pngh_string() {
- echo "$(grep -m1 "define PNG_LIBPNG_VER_STRING" "$1" | \
- grep -Eo '"[^"]+"' | grep -Eo '[^"]+')"
-}
-
-# returns major minor version numbers from png.h
-pngh_majmin() {
- local MAJ=$(grep -m1 "define PNG_LIBPNG_VER_MAJOR" "$1" | grep -Eo "[0-9]+")
- local MIN=$(grep -m1 "define PNG_LIBPNG_VER_MINOR" "$1" | grep -Eo "[0-9]+")
- echo "${MAJ}${MIN}"
-}
-
-error() {
- status "$1" "error ... $2"
- echo
- exit 1
-}
-
-echo
-
-# /tmp, because mingw has problems opening /dev/null and gives false negative
-if ! echo "int main(){}" | "$CC" -xc -std=c99 -o pngquant-gcccheck - > /dev/null; then
- rm -f pngquant-gcccheck
- if [ "$SKIP_CC_CHECK" -eq 1 ]; then
- status "Compiler" "$CC failed to compile anything (make sure it's installed and supports C99)"
- else
- error "Compiler" "$CC failed to compile anything (make sure it's installed and supports C99)"
- fi
-fi
-rm -f pngquant-gcccheck
-
-status "Compiler" "$CC"
-
-# init flags
-CFLAGS=${CFLAGS:--fno-math-errno -funroll-loops -fomit-frame-pointer -Wall}
-cflags "-std=c99 -I."
-
-# DEBUG
-if [ -z "$DEBUG" ]; then
- cflags "-O3 -DNDEBUG"
- status "Debug" "no"
-else
- cflags "-O1 -g -DDEBUG"
- status "Debug" "yes"
-fi
-
-# SSE
-if [ "$SSE" = 'auto' ]; then
- SSE=0
- if type uname > /dev/null; then
- if [[ "$(uname -m)" =~ "amd64" || "$(uname -m)" =~ "x86_64" ||
- "$(grep -E -m1 "^flags" /proc/cpuinfo)" =~ "sse" ]]; then
- SSE=1
- fi
- fi
-fi
-
-if [ "$SSE" -eq 1 ]; then
- status "SSE" "yes"
- cflags "-DUSE_SSE=1"
- cflags "-msse"
- # Silence a later ICC warning due to -msse working slightly different.
- conditional_cflags "-wd10121"
- # Must be set explicitly for GCC on x86_32. Other compilers imply it.
- conditional_cflags "-mfpmath=sse" "-msse"
-elif [ "$SSE" -eq 0 ]; then
- status "SSE" "no"
- cflags "-DUSE_SSE=0"
-fi
-
-# OpenMP
-if [ -n "$OPENMP" ]; then
- if [ "static" = "$OPENMP" ]; then
- OPENMPFLAGS="-static-libgcc -Bstatic -fopenmp -Bdynamic"
- else
- OPENMPFLAGS="-fopenmp"
- fi
- if [[ "$("$CC" -xc -E $OPENMPFLAGS <(echo "#ifdef _OPENMP
- #include <omp.h>
- #endif") 2>&1)" =~ "omp_get_thread_num" ]]; then
- cflags "$OPENMPFLAGS"
- lflags "$OPENMPFLAGS"
- status "OpenMP" "yes"
- else
- error "OpenMP" "not supported by compiler (please install a compiler that supports OpenMP (e.g. gcc) and specify it with the CC= argument)"
- fi
-else
- # silence warnings about omp pragmas
- cflags "-Wno-unknown-pragmas"
- conditional_cflags "-wd3180" # ICC
- status "OpenMP" "no"
-fi
-
-# Cocoa
-if [[ "$OSTYPE" =~ "darwin" ]]; then
- if [ -z "${MACOSX_DEPLOYMENT_TARGET+isset}" ]; then
- cflags "-mmacosx-version-min=10.9"
- lflags "-mmacosx-version-min=10.9"
- fi
-fi
-
-# pairs of possible *.h and lib*.so locations
-DIRS=()
-
-if command -v >/dev/null libpng-config; then
- DIRS+=("$(libpng-config --prefix) $(libpng-config --libdir)")
-fi
-
-if [ -n $"LIQSRCDIR" ]; then
- DIRS+=("$LIQSRCDIR" "$LIQSRCDIR") # local libimagequant
-fi
-
-DIRS+=(
- "/usr/local/include /usr/local/lib"
- "/usr/include /usr/lib64"
- "/usr/include /usr/lib"
- "/opt/local/include /opt/local/lib" # macports
- )
-
-if [[ "$OSTYPE" =~ "darwin" ]]; then
- SOLIBSUFFIX=dylib
-
- # Search Developer SDK paths, since Apple seems to have dropped the standard Unixy ones
- XCODE_CMD="xcode-select"
- XCODE_PATH=$($XCODE_CMD -p)
- DIRS+=("$XCODE_PATH/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include $XCODE_PATH/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib")
- DIRS+=("$XCODE_PATH/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include $XCODE_PATH/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib")
-elif [[ "$OSTYPE" =~ "msys" ]]; then
- SOLIBSUFFIX=dll
-else
- SOLIBSUFFIX=so
-fi
-
-
-# libimagequant
-if [ "./lib" = "$LIQSRCDIR" -a -d ".git" -a ! -f "lib/Cargo.toml" ]; then
- git submodule init && git submodule update;
-fi
-
-
-if find_library "imagequant" "imagequant" "libimagequant.h" "libimagequant.a" "libimagequant.$SOLIBSUFFIX*"; then
- if [ -n "$LIBRARY_FOUND_VERSION" ]; then
- VERSION=$LIBRARY_FOUND_VERSION
- elif [ -n "$LIBRARY_FOUND_HEADER" ]; then
- VERSION=$(grep LIQ_VERSION_STRING "$LIBRARY_FOUND_HEADER" | grep -Eo "2\.[0-9.]+")
- else
- VERSION=unknown
- fi
-
- if [ -n "$LIBRARY_FOUND_BUILD" ]; then
- STATICLIBDEPS="$LIBRARY_FOUND_BUILD/libimagequant.h $LIBRARY_FOUND_BUILD/libimagequant.a"
- LIQSRCDIR="$LIBRARY_FOUND_BUILD"
- fi
-else
- if [ -n "$LIQSRCDIR" -a ! -f "$LIQSRCDIR"/libimagequant.h ]; then
- echo "If you're using git, do clone with --recursive, or download from https://github.com/ImageOptim/libimagequant"
- error "imagequant" "libimagequant.h not found in $LIQSRCDIR/"
- else
- error "imagequant" "not found. Get it from https://github.com/ImageOptim/libimagequant and build it in ./lib/"
- fi
-fi
-
-# libpng
-# try if given flags are enough
-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"
- HAS_LIBPNG=1
-fi
-
-if [ "$HAS_LIBPNG" -eq 0 ]; then
- # try static in the given directory
- PNGH=$(find_h "$LIBPNG_DIR" "png.h")
- if [ -n "$PNGH" ]; then
- PNGH_STRING=$(pngh_string "$PNGH")
- PNGH_MAJMIN=$(pngh_majmin "$PNGH")
- if [[ -n "$PNGH_STRING" && -n "$PNGH_MAJMIN" ]]; then
- LIBPNGA=$(find_f "$LIBPNG_DIR" "libpng${PNGH_MAJMIN}.a")
- if [ -z "$LIBPNGA" ]; then
- LIBPNGA=$(find_f "$LIBPNG_DIR" "libpng.a")
- fi
- if [ -n "$LIBPNGA" ]; then
- cflags "-I${PNGH%/*}"
- lflags "${LIBPNGA}"
- status "libpng" "static (${PNGH_STRING})"
- HAS_LIBPNG=1
- fi
- fi
- fi
-fi
-# try shared
-if [ "$HAS_LIBPNG" -eq 0 ]; then
- if find_pkgconfig libpng; then
- HAS_LIBPNG=1
- else
- for i in "${DIRS[@]}"; do
- DIR=($i)
- PNGH=$(find_h "${DIR[0]}" "png.h")
- if [ -n "$PNGH" ]; then
- PNGH_STRING=$(pngh_string "$PNGH")
- PNGH_MAJMIN=$(pngh_majmin "$PNGH")
- if [[ -n "$PNGH_STRING" && -n "$PNGH_MAJMIN" ]]; then
- LIBPNGSO=$(find_f "${DIR[1]}" "libpng${PNGH_MAJMIN}.$SOLIBSUFFIX*")
- if [ -n "$LIBPNGSO" ]; then
- cflags "-I${PNGH%/*}"
- lflags "-L${LIBPNGSO%/*} -lpng${PNGH_MAJMIN}"
- status "libpng" "shared (${PNGH_STRING})"
- HAS_LIBPNG=1
- break
- fi
- fi
- fi
- done
- fi
-fi
-if [ "$HAS_LIBPNG" -eq 0 ]; then
- if [[ "$OSTYPE" =~ "darwin" ]]; then
- LIBPNG_CMD='`brew install libpng`'
- else
- 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
-
-# zlib
-if ! find_library "zlib" "z" "zlib.h" "libz.a" "libz.$SOLIBSUFFIX*"; then
- if ! find_library "zlib" "z" "zlib.h" "zlib.a" "zlib.$SOLIBSUFFIX*"; then
- error "zlib" "not found (please install zlib-devel package)"
- fi
-fi
-
-# lcms2
-if [ "$LCMS2" != 0 ]; then
- if find_library "lcms2" "lcms2" "lcms2.h" "liblcms2.a" "liblcms2.$SOLIBSUFFIX*"; then
- cflags "-DUSE_LCMS=1"
- else
- if [ "$LCMS2" = 'auto' ]; then
- status "lcms2" "no"
- else
- error "lcms2" "not found (please install libcms2-devel package)"
- fi
- fi
-else
- status "lcms2" "no"
-fi
-
-echo
-
-# As of GCC 4.5, 387 fp math is significantly slower in C99 mode without this.
-# Note: CPUs without SSE2 use 387 for doubles, even when SSE fp math is set.
-conditional_cflags "-fexcess-precision=fast"
-
-# Intel C++ Compiler
-
-# ICC does usually only produce fast(er) code when it can optimize to the full
-# capabilites of the (Intel) CPU. This is equivalent to -march=native for GCC.
-conditional_cflags "-xHOST"
-
-# Disable unsafe fp optimizations and enforce fp precision as set in the source.
-conditional_cflags "-fp-model source"
-
-# Silence a gold linker warning about string misalignment.
-conditional_cflags "-falign-stack=maintain-16-byte"
-
-lflags "-lm" # Ubuntu requires this library last, issue #38
-
-if [ -n "$EXTRA_CFLAGS" ]; then
- cflags "$EXTRA_CFLAGS"
-fi
-
-if [ -n "$EXTRA_LDFLAGS" ]; then
- lflags "$EXTRA_LDFLAGS"
-fi
-
-# Overwrite previous configuration.
-echo "
-# auto-generated by configure
-PREFIX = $PREFIX
-VERSION = $VERSION
-CC = $CC
-CFLAGS = $CFLAGS
-LDFLAGS = $LDFLAGS
-SOLIBSUFFIX = $SOLIBSUFFIX
-STATICLIBDEPS = $STATICLIBDEPS
-LIQSRCDIR = $LIQSRCDIR
-LIQCONFIGUREFLAGS = $(printf "'%s' " "${LIQCONFIGURE[@]}")
-" > "$CONFIG"
-
diff --git a/debian/changelog b/debian/changelog
index bcd7611..c17cf15 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+pngquant (3.0.1-1) UNRELEASED; urgency=low
+
+ * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk> Sun, 13 Aug 2023 23:29:46 -0000
+
pngquant (2.17.0-1) unstable; urgency=medium
* Fix watch file
diff --git a/pngquant.c b/pngquant.c
index 611dbaa..cb8983f 100644
--- a/pngquant.c
+++ b/pngquant.c
@@ -55,10 +55,10 @@ use --force to overwrite. See man page for full list of options.\n";
#endif
#include "rwpng.h" /* typedefs, common macros, public prototypes */
-#include "libimagequant.h" /* if it fails here, run: git submodule update; ./configure; or add -Ilib to compiler flags */
+#include "libimagequant.h" /* if it fails here, run: git submodule update or add -Ilib to compiler flags */
#include "pngquant_opts.h"
-char *PNGQUANT_VERSION = LIQ_VERSION_STRING " (September 2021)";
+char *PNGQUANT_VERSION = LIQ_VERSION_STRING " (January 2022)";
static pngquant_error prepare_output_image(liq_result *result, liq_image *input_image, rwpng_color_transform tag, png8_image *output_image);
static void set_palette(liq_result *result, png8_image *output_image);
diff --git a/pngquant.spec b/pngquant.spec
deleted file mode 100644
index 687205b..0000000
--- a/pngquant.spec
+++ /dev/null
@@ -1,60 +0,0 @@
-Name: pngquant
-Version: 2.17.0
-Release: 1%{?dist}
-Summary: PNG quantization tool for reducing image file size
-# New code is under GPL, forked from old BSD-like
-License: GPLv3+ and BSD
-URL: https://pngquant.org
-Source0: https://github.com/kornelski/pngquant/archive/%{version}.tar.gz
-BuildRequires: libpng-devel%{?_isa} >= 1.6.0
-BuildRequires: zlib-devel%{?_isa} >= 1.2.3-1
-BuildRequires: gcc%{?_isa} >= 4.2-1
-Requires: libpng%{?_isa} >= 1.6.0
-Requires: zlib%{?isa} >= 1.2.3-1
-
-%description
-pngquant converts 24/32-bit RGBA PNG images to high-quality 8-bit palette
-with alpha channel preserved. Quantization significantly reduces file sizes.
-Such images are fully standards-compliant and supported by all web browsers.
-
-%prep
-%setup -q -n pngquant-%{version}
-
-%build
-./configure --prefix=%{_prefix}
-make %{?_smp_mflags}
-
-
-%install
-rm -rf %{buildroot}
-mkdir -p %{buildroot}/%{_bindir}
-make install PREFIX=%{_prefix} DESTDIR=%{buildroot}
-install -Dpm0755 pngquant %{buildroot}/%{_bindir}/pngquant
-install -Dpm0644 pngquant.1 %{buildroot}/%{_mandir}/man1/pngquant.1
-
-
-%files
-%defattr(-,root,root,-)
-%doc README.md CHANGELOG COPYRIGHT
-%{_bindir}/pngquant
-%{_mandir}/man1/pngquant.1*
-
-
-%changelog
-
-* Fri Sep 12 2014 Michael Dec <grepwood@sucs.org> 1.8.3-1
-- Update to latest upstream version and corrected the .spec
-
-* Thu May 03 2012 Craig Barnes <cr@igbarn.es> - 1.7.2-1
-- Update to latest upstream version
-
-* Sun Jan 15 2012 Craig Barnes <cr@igbarn.es> - 1.7.0-1
-- Update to latest upstream version
-
-* Mon Jan 09 2012 Craig Barnes <cr@igbarn.es> - 1.6.4-1
-- Update to latest version
-- Remove Makefile patch (merged upstream)
-- Use prefix macro when installing (upstream changed the default prefix)
-
-* Wed Dec 28 2011 Craig Barnes <cr@igbarn.es> - 1.6.2-1
-- Initial package
diff --git a/rust/bin.rs b/rust/bin.rs
index de850b0..82809f7 100644
--- a/rust/bin.rs
+++ b/rust/bin.rs
@@ -4,10 +4,6 @@
** See COPYRIGHT file for license.
*/
-#[cfg(feature = "openmp")]
-extern crate openmp_sys;
-
-extern crate imagequant_sys;
extern crate libpng_sys;
#[cfg(feature = "cocoa")]
@@ -15,13 +11,11 @@ pub mod rwpng_cocoa;
#[cfg(feature = "lcms2")]
extern crate lcms2_sys;
-
use imagequant_sys::liq_error::LIQ_OK;
use imagequant_sys::*;
use libc::FILE;
-use crate::ffi::PNGQUANT_VERSION;
use crate::ffi::pngquant_internal_print_config;
-use std::os::raw::{c_uint, c_char, c_void};
+use std::os::raw::{c_uint, c_char};
use std::ptr;
use std::io;
@@ -32,11 +26,11 @@ use crate::ffi::*;
use crate::ffi::pngquant_error::*;
fn unwrap_ptr(opt: Option<&CString>) -> *const c_char {
- opt.map(|c| c.as_ptr()).unwrap_or(ptr::null())
+ opt.map_or(ptr::null(), |c| c.as_ptr())
}
fn print_full_version(fd: &mut dyn io::Write, c_fd: *mut FILE) {
- let _ = writeln!(fd, "pngquant, {} (Rust), by Kornel Lesinski, Greg Roelofs.", unsafe{CStr::from_ptr(PNGQUANT_VERSION)}.to_str().unwrap());
+ let _ = writeln!(fd, "pngquant, {} (Rust), by Kornel Lesinski, Greg Roelofs.", env!("CARGO_PKG_VERSION"));
let _ = fd.flush();
unsafe{pngquant_internal_print_config(c_fd);}
let _ = writeln!(fd);
@@ -71,7 +65,7 @@ fn parse_quality(quality: &str) -> Option<(u8, u8)> {
// quality="%d"
(t, None) => {
let target = t.parse().ok()?;
- (((target as u16)*9/10) as u8, target)
+ ((u16::from(target)*9/10) as u8, target)
},
// quality="%d-%d"
(l, Some(t)) => {
@@ -80,8 +74,8 @@ fn parse_quality(quality: &str) -> Option<(u8, u8)> {
})
}
-unsafe extern "C" fn log_callback(_a: &liq_attr, msg: *const c_char, _user: *mut c_void) {
- eprintln!("{}", CStr::from_ptr(msg).to_str().unwrap());
+unsafe extern "C" fn log_callback(_a: &liq_attr, msg: *const c_char, _user: AnySyncSendPtr) {
+ println!("{}", CStr::from_ptr(msg).to_str().unwrap());
}
fn main() {
@@ -116,7 +110,7 @@ fn run() -> ffi::pngquant_error {
let mut m = match opts.parse(args) {
Ok(m) => m,
Err(err) => {
- eprintln!("{}", err);
+ eprintln!("{err}");
print_usage(&mut io::stderr());
return MISSING_ARGUMENT;
},
@@ -131,7 +125,7 @@ fn run() -> ffi::pngquant_error {
let colors = if let Some(c) = m.free.get(0).and_then(|s| s.parse().ok()) {
m.free.remove(0);
- if m.free.len() == 0 {
+ if m.free.is_empty() {
m.free.push("-".to_owned()); // stdin default
}
c
@@ -186,7 +180,7 @@ fn run() -> ffi::pngquant_error {
}
if options.print_version {
- println!("{}", unsafe { CStr::from_ptr(PNGQUANT_VERSION) }.to_str().unwrap());
+ println!("{}", env!("CARGO_PKG_VERSION"));
return SUCCESS;
}
@@ -202,20 +196,21 @@ fn run() -> ffi::pngquant_error {
return SUCCESS;
}
- let liq = unsafe { liq_attr_create().as_mut().unwrap() };
+ let mut liq = liq_attr_create().unwrap();
+ let liq = &mut *liq;
if options.verbose {
- unsafe{liq_set_log_callback(liq, Some(log_callback), ptr::null_mut());}
+ unsafe { liq_set_log_callback(liq, log_callback, Default::default()); }
options.log_callback = Some(log_callback);
}
if m.opt_present("transbug") {
- unsafe{liq_set_last_index_transparent(liq, true as _);}
+ liq_set_last_index_transparent(liq, i32::from(true));
}
if let Some(speed) = m.opt_str("speed") {
let set_ok = speed.parse().ok()
- .filter(|&s: &u8| s>=1 && s <=11)
+ .filter(|&s: &u8| (1..=11).contains(&s))
.map_or(false, |mut speed| {
if speed >= 10 {
options.fast_compression = true;
@@ -224,7 +219,7 @@ fn run() -> ffi::pngquant_error {
options.floyd = 0.0;
}
}
- LIQ_OK == unsafe{liq_set_speed(liq, speed.into())}
+ LIQ_OK == liq_set_speed(liq, speed.into())
});
if !set_ok {
eprintln!("Speed should be between 1 (slow) and 11 (fast).");
@@ -235,7 +230,7 @@ fn run() -> ffi::pngquant_error {
if let Some(q) = quality.as_ref() {
if let Some((limit, target)) = parse_quality(q) {
options.min_quality_limit = limit > 0;
- if LIQ_OK != unsafe { liq_set_quality(liq, limit.into(), target.into()) } {
+ if LIQ_OK != liq_set_quality(liq, limit.into(), target.into()) {
eprintln!("Quality value(s) must be numbers in range 0-100.");
return INVALID_ARGUMENT;
}
@@ -245,12 +240,12 @@ fn run() -> ffi::pngquant_error {
}
}
- if options.colors > 0 && LIQ_OK != unsafe { liq_set_max_colors(liq, options.colors as _) } {
+ if options.colors > 0 && LIQ_OK != liq_set_max_colors(liq, options.colors as _) {
eprintln!("Number of colors must be between 2 and 256.");
return INVALID_ARGUMENT;
}
- if options.posterize > 0 && LIQ_OK != unsafe { liq_set_min_posterization(liq, options.posterize as _) } {
+ if options.posterize > 0 && LIQ_OK != liq_set_min_posterization(liq, options.posterize as _) {
eprintln!("Posterization should be number of bits in range 0-4.");
return INVALID_ARGUMENT;
}
@@ -262,7 +257,7 @@ fn run() -> ffi::pngquant_error {
// new filename extension depends on options used. Typically basename-fs8.png
if options.extension.is_null() {
- options.extension = if options.floyd > 0. { b"-fs8.png\0" } else { b"-or8.png\0" }.as_ptr() as *const _;
+ options.extension = if options.floyd > 0. { b"-fs8.png\0" } else { b"-or8.png\0" }.as_ptr().cast();
}
if !options.output_file_path.is_null() && options.num_files != 1 {
@@ -284,7 +279,6 @@ fn run() -> ffi::pngquant_error {
return MISSING_ARGUMENT;
}
- let retval = unsafe {pngquant_main_internal(&mut options, liq)};
- unsafe {liq_attr_destroy(liq);}
- retval
+
+ unsafe {pngquant_main_internal(&mut options, liq)}
}
diff --git a/rust/build.rs b/rust/build.rs
index 3697566..be19c3e 100644
--- a/rust/build.rs
+++ b/rust/build.rs
@@ -8,10 +8,6 @@ fn main() {
cc.define("PNGQUANT_NO_MAIN", Some("1"));
- if cfg!(feature = "openmp") {
- cc.flag(&env::var("DEP_OPENMP_FLAG").unwrap());
- }
-
if cfg!(feature = "cocoa") {
if cfg!(feature = "lcms2") {
println!("cargo:warning=Don't use both lcms2 and cocoa features at the same time, see --no-default-features");
@@ -42,6 +38,7 @@ fn main() {
cc.include(dunce::simplified(Path::new(&p)));
} else {
cc.include("lib");
+ cc.include("lib/imagequant-sys");
}
if let Ok(p) = env::var("DEP_PNG_INCLUDE") {
diff --git a/rust/ffi.rs b/rust/ffi.rs
index 9665575..d034faf 100644
--- a/rust/ffi.rs
+++ b/rust/ffi.rs
@@ -1,14 +1,14 @@
#![allow(non_camel_case_types)]
use libc::FILE;
-use std::os::raw::*;
use imagequant_sys::*;
+use std::os::raw::{c_char, c_uint, c_void};
extern "C" {
- pub static PNGQUANT_VERSION: *const c_char;
pub static PNGQUANT_USAGE: *const c_char;
pub fn pngquant_internal_print_config(fd: *mut libc::FILE);
+ #[allow(improper_ctypes)]
pub fn pngquant_main_internal(options: &mut pngquant_options, liq: *mut liq_attr) -> pngquant_error;
pub fn pngquant_c_stderr() -> *mut FILE;
pub fn pngquant_c_stdout() -> *mut FILE;
@@ -18,6 +18,7 @@ extern "C" {
#[derive(Debug, Copy, Clone)]
#[allow(dead_code)]
#[allow(non_camel_case_types)]
+#[allow(clippy::upper_case_acronyms)]
#[non_exhaustive]
pub enum pngquant_error {
SUCCESS = 0,
@@ -39,8 +40,8 @@ pub enum pngquant_error {
#[repr(C)]
pub struct pngquant_options {
- pub fixed_palette_image: *mut liq_image,
- pub log_callback: liq_log_callback_function,
+ pub fixed_palette_image: *mut liq_image<'static>,
+ pub log_callback: Option<liq_log_callback_function>,
pub log_callback_user_info: *mut c_void,
pub quality: *const c_char,
pub extension: *const c_char,
diff --git a/rwpng.c b/rwpng.c
index 8405a3a..4cde055 100644
--- a/rwpng.c
+++ b/rwpng.c
@@ -12,7 +12,7 @@
#include <string.h>
#include <limits.h>
-#include "png.h" /* if this include fails, you need to install libpng (e.g. libpng-devel package) and run ./configure */
+#include "png.h" /* if this include fails, you need to install libpng (e.g. libpng-devel package) */
#include "rwpng.h"
#if USE_LCMS
#include "lcms2.h"
diff --git a/snapcraft.yaml b/snapcraft.yaml
index d78296d..aeb6c42 100644
--- a/snapcraft.yaml
+++ b/snapcraft.yaml
@@ -1,5 +1,5 @@
name: pngquant
-version: 2.17.0
+version: 3.0.0
summary: pngquant
description: |
Lossy PNG compressor — pngquant command based
@@ -18,18 +18,14 @@ parts:
pngquant:
source-type: git
source: https://github.com/kornelski/pngquant.git
- source-tag: 2.17.0
- plugin: autotools
- configflags:
- - --with-openmp
+ source-tag: 3.0.0-beta.1
+ plugin: rust
build-packages:
- gcc
- - make
- libpng-dev
- zlib1g-dev
- liblcms2-dev
stage-packages:
- - libgomp1
- libpng16-16
- zlib1g
- liblcms2-2
diff --git a/test/oss_fuzz_build.sh b/test/oss_fuzz_build.sh
deleted file mode 100755
index 60f381b..0000000
--- a/test/oss_fuzz_build.sh
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/bash -eu
-
-# Build libpng
-pushd $SRC/pngquant/libpng
-cat scripts/pnglibconf.dfa | \
- sed -e "s/option WARNING /option WARNING disabled/" \
-> scripts/pnglibconf.dfa.temp
-mv scripts/pnglibconf.dfa.temp scripts/pnglibconf.dfa
-autoreconf -f -i
-./configure \
- --prefix="$WORK" \
- --disable-shared \
- --enable-static \
- LDFLAGS="-L$WORK/lib" \
- CPPFLAGS="-I$WORK/include"
-make -j$(nproc)
-make install
-popd
-
-cd $SRC/pngquant
-
-# Remove "static" from read_image
-sed 's/static pngquant_error read_image/pngquant_error read_image/g' -i pngquant.c
-
-# Build pngquant
-make -j$(nproc) V=1
-
-# Rename "main()" to "main2" and compile
-# pngquant.c again. Otherwise libfuzzer will complain
-sed 's/int main(/int main2(/g' -i pngquant.c
-$CC $CFLAGS -c pngquant.c -o pngquant.o -I. -O3 \
- -DNDEBUG -DUSE_SSE=1 -msse -mfpmath=sse \
- -Wno-unknown-pragmas -I./lib -I./libpng \
- -I/usr/include
-
-# Collect all .o files into fuzz_lib.a
-find . -name "*.o" -exec ar rcs fuzz_lib.a {} \;
-
-# Build the fuzzer(s)
-$CC $CFLAGS -c test/fuzzer.c -o fuzzer.o -I. \
- -O3 -DNDEBUG -DUSE_SSE=1 -msse -mfpmath=sse \
- -Wno-unknown-pragmas -I./lib -I./libpng \
- -I/usr/include
-
-$CC $CFLAGS fuzzer.o -I. -O3 -DNDEBUG -DUSE_SSE=1 \
- -msse -mfpmath=sse -Wno-unknown-pragmas \
- ./lib/libimagequant.a ./libpng/.libs/libpng16.a \
- -L/usr/lib/x86_64-linux-gnu -lz -lm $LIB_FUZZING_ENGINE \
- fuzz_lib.a -o $OUT/fuzzer
-
-# Create seed corpus
-zip $OUT/fuzzer_seed_corpus.zip $SRC/pngquant/test/img/test.png
diff --git a/test/test.c b/test/test.c
index 6022629..e8e7818 100644
--- a/test/test.c
+++ b/test/test.c
@@ -127,7 +127,7 @@ static void test_fixed_colors_order() {
liq_color colors[17] = {
{0,0,0,0}, {1,1,1,1}, {2,2,2,2}, {3,3,3,3}, {4,4,4,4}, {5,4,4,4},
{6,4,4,4}, {6,7,4,4}, {6,7,8,4}, {6,7,8,9}, {10,7,8,9}, {10,11,8,9},
- {10,11,12,9}, {10,11,12,13}, {14,11,12,13}, {14,15,12,13}, {14,15,16,13},
+ {10,11,12,9}, {10,11,12,13}, {14,11,12,13}, {14,15,12,13}, {253,254,255,254},
};
for(int i=0; i < 17; i++) {