Commit 8f6aecb8 authored by Andreas Tille's avatar Andreas Tille

New upstream version 2.12.2

parent f8b0fe79
......@@ -8,5 +8,8 @@ build
DerivedData
pngquant
lib/libimagequant.a
*.obj
*.lib
config.mk
test/test
target/
language: c
sudo: required
os:
- linux
- osx
before_install:
- if [[ $TRAVIS_OS_NAME = "osx" ]]; then
brew install lcms2;
elif [[ $TRAVIS_OS_NAME = "linux" ]]; then
echo "deb-src http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list;
sudo apt-get update -q;
sudo apt-get build-dep -y libpng16-16;
sudo apt-get source -b -t xenial libpng16-16;
fi
script:
- ./configure --with-lcms2
- make
- make test
version 2.12
------------
- improved speed on large images
version 2.11
------------
- fixed wildcard support on Windows
- fixed argument parsing on Windows
version 2.10
------------
- supports building with Rust/Cargo
- supports dynamic linking with system-wide libimagequant
version 2.9
-----------
- added support for `-o -`
- windows/JNI build fixes
version 2.8
-----------
- libimagequant is a separate project
......
pngquant and libimagequant are derived from code by Jef Poskanzer and Greg Roelofs
licensed under pngquant's original licenses (near the end of this file),
and contain extensive changes and additions by Kornel Lesiński licensed under GPL v3.
and contain extensive changes and additions by Kornel Lesiński
licensed under GPL v3 or later.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
pngquant © 2009-2016 by Kornel Lesiński.
pngquant © 2009-2018 by Kornel Lesiński.
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
......
[package]
authors = ["Kornel Lesiński <kornel@pngquant.org>"]
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"
include = ["/rwpng*", "/pngquant.c", "/rust/*", "/COPYRIGHT", "/Cargo.toml", "/README.md"]
keywords = ["quantization", "palette", "image", "pngquant", "compression"]
license = "GPL-3.0+"
name = "pngquant"
readme = "README.md"
repository = "https://github.com/kornelski/pngquant.git"
version = "2.12.2"
[[bin]]
name = "pngquant"
path = "rust/bin.rs"
[build-dependencies]
cc = "1.0.3"
dunce = "0.1.0"
[dependencies]
getopts = "0.2.15"
libc = "0.2.33"
libpng-sys = "1.0.1"
wild = "2.0.0"
[dependencies.cocoa_image]
optional = true
version = "1.0.0"
[dependencies.imagequant-sys]
path = "lib"
version = "2.12.0"
[dependencies.lcms2-sys]
optional = true
version = "2.4.4"
[dependencies.openmp-sys]
optional = true
version = "0.1.2"
[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"]
png-static = ["libpng-sys/static"]
static = ["lcms2-static", "png-static", "openmp-static"]
sse = ["imagequant-sys/sse"]
alloc_system = []
[profile.release]
lto = true
## Compiling on Linux, *BSD and macOS
(For instructions for Windows see section below.)
### Using GNU/Makefile
To get the code:
$ git clone --recursive https://github.com/pornel/pngquant.git
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`.
To build pngquant from source on macOS and most Linux distributions, run:
There's an optional `./configure` step (see sections below). Run:
$ make
make
It will create pngquant executable in the current directory. If you'd like
It will create `pngquant` executable in the current directory. If you'd like
to install it system-wide:
$ sudo make install
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,
and on Windows the MinGW compiler (MSVC does not support C99).
pngquant uses GNU Makefile. To compile on FreeBSD you will need to use `gmake`.
pngquant will compile with libpng 1.2, but you should use 1.5 or later.
Avoid Linux distros that ship with libpng 1.2. It is old and buggy.
Use libpng 1.6 or later.
### Using Rust/Cargo
##Compilation with OpenMP
If you have Rust, you can also build with `cargo build`.
$ ./configure --with-openmp && make
### Custom static libpng
This makes pngquant faster in wall-clock time on multicore machines when one
image at a time is processed.
Extract libpng source code as a *sub*directory of pngquant source directory.
Build static libpng (`./configure --enable-static && make`), and then
`./configure && make` pngquant.
However, it increases total CPU time used, and thus it's not most optimal
for server-side and parallelized batch jobs which run many pngquant
instances at a time.
When building with Cargo, `export PNG_STATIC=1`.
On OS X you may need to install gcc and add `CC=gcc-4.9` to `./configure`,
because clang doesn't support OpenMP (yet).
## Windows
Compiling on Windows is supported only via Rust/Cargo.
1. Install git (msys-git).
2. Install Visual C++ 2015 Build Tools.
3. [Install Rust](https://www.rust-lang.org/install.html)
4. Restart Windows.
Open Git's Bash prompt and run:
git clone -b msvc --recursive https://github.com/kornelski/pngquant.git
cd pngquant
This will create pngquant folder in your user folder. And then run:
cargo build --release
It will create `pngquant.exe` in `target/release` subfolder.
## Compilation with OpenMP
cargo build --release --features=openmp # or
cargo build --release --features=openmp-static
On macOS you may need to install gcc and run `export CC=gcc-7` first,
because clang doesn't support OpenMP (yet).
##Compilation without Cocoa image reader
## Compilation without Cocoa image reader
Mac OS X version uses Cocoa to read images. This adds support for color profiles
and other image formats as input. `./configure --without-cocoa` switches back
to libpng.
macOS version can use Cocoa to read images. This adds support for color profiles
and other image formats as input.
cargo build --release --features=cocoa
##Compilation with Little CMS 2
## Compilation with Little CMS 2
$ ./configure --with-lcms2 && make
Little CMS library is used by default.
Enables support for ICC v2/v4 color profiles when reading images.
Requires Little CMS library available via `pgk-config` (e.g. install `liblcms2-dev`).
It's linked dynamically if `pkg-config` is working (e.g. install `liblcms2-dev`).
Otherwise uses static build as a fallback.
Set `export LCMS2_STATIC=1` to force static linking.
##Compilation of `libimagequant.a` only
## Compilation of `libimagequant.a` only
If you want to use pngquant's conversion algorithm without loading/saving PNG
files, then you can run `make` in the `lib/` directory.
The library doesn't need libpng or zlib.
files, then you can run `make` or `cargo build` in the `lib/` directory.
The library doesn't need libpng nor zlib.
-include config.mk
LIQSRCDIR ?= lib
BIN ?= pngquant
BINPREFIX ?= $(DESTDIR)$(PREFIX)/bin
MANPREFIX ?= $(DESTDIR)$(PREFIX)/share/man
OBJS = pngquant.o rwpng.o
COCOA_OBJS = rwpng_cocoa.o
OBJS = pngquant.o pngquant_opts.o rwpng.o
ifeq (1, $(COCOA_READER))
OBJS += $(COCOA_OBJS)
endif
STATICLIB = lib/libimagequant.a
SHAREDLIB = lib/libimagequant.so
DISTFILES = *.[chm] pngquant.1 Makefile configure README.md INSTALL CHANGELOG COPYRIGHT
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 = lib/*.[ch] lib/COPYRIGHT lib/README.md lib/configure lib/Makefile
LIBDISTFILES = $(LIQSRCDIR)/*.[ch] $(LIQSRCDIR)/COPYRIGHT $(LIQSRCDIR)/README.md $(LIQSRCDIR)/configure $(LIQSRCDIR)/Makefile $(LIQSRCDIR)/Cargo.toml
TESTBIN = test/test
all: $(BIN)
staticlib: $(STATICLIB)
$(STATICLIB): config.mk $(LIBDISTFILES)
$(MAKE) -C lib static
sharedlib: lib/libimagequant.h
$(MAKE) -C lib shared
$(LIQSRCDIR)/config.mk: config.mk
( cd '$(LIQSRCDIR)'; ./configure $(LIQCONFIGUREFLAGS) )
$(SHAREDLIB): config.mk sharedlib
$(STATICLIB): $(LIQSRCDIR)/config.mk $(LIBDISTFILES)
$(MAKE) -C '$(LIQSRCDIR)' static
$(OBJS): $(wildcard *.h) config.mk
rwpng_cocoa.o: rwpng_cocoa.m
$(CC) -Wno-enum-conversion -c $(CFLAGS) -o $@ $< &> /dev/null || clang -Wno-enum-conversion -c -O3 $(CFLAGS) -o $@ $<
$(BIN): $(OBJS) $(STATICLIBDEPS)
$(CC) $(OBJS) $(CFLAGS) $(LDFLAGS) -o $@
$(BIN): $(OBJS) $(STATICLIB)
$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@
$(TESTBIN): test/test.o $(STATICLIB)
$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@
$(TESTBIN): test/test.o $(STATICLIBDEPS)
$(CC) test/test.o $(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)
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
mkdir -p $(TARNAME)/lib/rust $(TARNAME)/lib/msvc-dist $(TARNAME)/rust
cp $(DISTFILES) $(TARNAME)
cp rust/*.rs $(TARNAME)/rust/
cp $(LIBDISTFILES) $(TARNAME)/lib
cp $(LIQSRCDIR)/rust/*.rs $(TARNAME)/lib/rust/
cp $(LIQSRCDIR)/msvc-dist/*.[ch] $(TARNAME)/lib/msvc-dist/
tar -czf $(TARFILE) --numeric-owner --exclude='._*' $(TARNAME)
rm -rf $(TARNAME)
-shasum $(TARFILE)
......@@ -79,20 +62,17 @@ uninstall:
rm -f '$(MANPREFIX)/man1/$(BIN).1'
clean:
$(MAKE) -C lib clean
rm -f '$(BIN)' $(OBJS) $(COCOA_OBJS) $(STATICLIB) $(TARFILE)
-test -n '$(LIQSRCDIR)' && $(MAKE) -C '$(LIQSRCDIR)' clean
rm -f '$(BIN)' $(OBJS) $(TARFILE)
distclean: clean
$(MAKE) -C lib distclean
-test -n '$(LIQSRCDIR)' && $(MAKE) -C '$(LIQSRCDIR)' distclean
rm -f config.mk pngquant-*-src.tar.gz
config.mk: lib/libimagequant.h
config.mk: Makefile
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
.PHONY: all clean dist distclean dll install uninstall test
.DELETE_ON_ERROR:
# pngquant 2
# pngquant 2 [![build](https://travis-ci.org/kornelski/pngquant.svg?branch=master)](https://travis-ci.org/kornelski/pngquant)
[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](https://pngquant.org) is a PNG compressor that significantly reduces file sizes by converting images to a more efficient 8-bit PNG format *with alpha channel* (often 60-80% smaller than 24/32-bit PNG files). Compressed images are fully standards-compliant and are supported by all web browsers and operating systems.
Quantized files are often 60-80% smaller than their 24/32-bit versions.
This utility works on Linux, Mac OS X and Windows. [This](https://github.com/pornel/pngquant) is the official `pngquant` repository.
[This](https://github.com/kornelski/pngquant) is the official `pngquant` repository. The compression engine is also available [as an embeddable library](https://github.com/ImageOptim/libimagequant).
## Usage
......@@ -14,23 +11,19 @@ This utility works on Linux, Mac OS X and Windows. [This](https://github.com/por
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
Generated files are both smaller and look much better.
* Significantly better quality of quantisation
## Features
- more accurate remapping of semitransparent colors
- special dithering algorithm that does not add noise in well-quantized areas of the image
- supports much larger number of colors in input images without degradation of quality
- gamma correction and optional color profile support (output is always in gamma 2.2 for web compatibility)
* High-quality palette generation
- advanced quantization algorithm with support for gamma correction and premultiplied alpha
- unique dithering algorithm that does not add unnecessary noise to the image
* Refactored and modernised code
* Configurable quality level
- automatically finds required number of colors and can skip images which can't be converted with the desired quality
- 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
* Fast, modern code
- based on a portable [libimagequant library](https://github.com/ImageOptim/libimagequant)
- C99 with no workarounds for legacy systems or compilers ([apart from Visual Studio](https://github.com/kornelski/pngquant/tree/msvc))
- multicore support (via OpenMP) and Intel SSE optimizations
## Options
......@@ -56,7 +49,7 @@ Don't write converted files if the conversion isn't worth it.
### `--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.
Speed/quality trade-off from 1 (slowest, highest quality, smallest files) to 11 (fastest, less consistent quality, light comperssion). The default is 3. It's recommended to keep the default, unless you need to generate images in real time (e.g. map tiles). Higher speeds are fine with 256 colors, but don't handle lower number of colors well.
### `--nofs`
......@@ -74,24 +67,12 @@ Reduce precision of the palette by number of bits. Use when the image will be di
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"
See [man page](https://github.com/kornelski/pngquant/blob/master/pngquant.1) (`man pngquant`) for the full list of options.
## 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.
* Under **GPL v3** or later with an additional [copyright notice](https://github.com/kornelski/pngquant/blob/master/COPYRIGHT) that must be kept for the older parts of the code.
* For use in non-GPL software (e.g. closed-source or App Store distribution) please ask kornel@pngquant.org for a commercial license.
* Or [a **commercial license**](https://supso.org/projects/pngquant) for use in non-GPL software (e.g. closed-source or App Store distribution). You can [get the license via Super Source](https://supso.org/projects/pngquant). Email kornel@pngquant.org if you have any questions.
......@@ -3,29 +3,19 @@
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=
LIQSRCDIR=./lib
LIQCONFIGURE=(--quiet)
SSE=auto
OPENMP=
LIBPNG_DIR=.
if [[ "$OSTYPE" =~ "darwin" ]]; then
COCOA_READER=auto
LCMS2=0
else
COCOA_READER=0
LCMS2=auto
fi
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"
......@@ -33,7 +23,7 @@ help() {
for i in "$@"; do
case $i in
--help)
--help|-h)
echo
help "--prefix=<dir> installation directory [$PREFIX]"
help "--extra-cflags=<flags> append to CFLAGS"
......@@ -42,6 +32,7 @@ for i in "$@"; do
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
......@@ -58,54 +49,70 @@ fi
# 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
COCOA_READER=0
;;
--without-lcms2)
LCMS2=0
;;
--with-cocoa)
COCOA_READER=1
LCMS2=0
LCMS2=auto
;;
--without-cocoa)
COCOA_READER=0
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)"
......@@ -152,10 +159,12 @@ find_h() {
find_pkgconfig() {
local LIBNAME=$1
if pkg-config --exists "$LIBNAME" &> /dev/null; then
cflags "$(pkg-config --cflags "$LIBNAME")"
lflags "$(pkg-config --libs "$LIBNAME")"
status "$LIBNAME" "shared ($(pkg-config --modversion "$LIBNAME"))"
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
return 1
......@@ -170,9 +179,10 @@ find_static() {
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"
status "$LIBNAME" "static ($APATH)"
return 0
fi
fi
......@@ -190,6 +200,7 @@ find_dynamic() {
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"
......@@ -206,6 +217,20 @@ find_library() {
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;
......@@ -246,10 +271,16 @@ error() {
echo
# basic check
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)"
# /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"
......@@ -268,9 +299,12 @@ fi
# SSE
if [ "$SSE" = 'auto' ]; then
if [[ "$(uname -m)" =~ (amd|x86_)64 ||
"$(grep -E -m1 "^flags" /proc/cpuinfo)" =~ "sse" ]]; then
SSE=1
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
......@@ -312,17 +346,8 @@ fi
# Cocoa
if [[ "$OSTYPE" =~ "darwin" ]]; then
cflags "-mmacosx-version-min=10.6"
lflags "-mmacosx-version-min=10.6"
if [ "$COCOA_READER" != 0 ] && "$CC" 2>/dev/null 1>/dev/null -xc -E <(echo "#import <Cocoa/Cocoa.h>"); then
COCOA_READER=1
cflags "-DUSE_COCOA=1"
lflags "-framework Cocoa"
status "Cocoa" "yes"
else
status "Cocoa" "no"
fi
cflags "-mmacosx-version-min=10.7"
lflags "-mmacosx-version-min=10.7"
fi
# pairs of possible *.h and lib*.so locations
......@@ -332,7 +357,13 @@ if command -v >/dev/null libpng-config; then
DIRS+=("$(libpng-config --prefix) $(libpng-config --libdir)")
fi
DIRS+=("/usr/local/include /usr/local/lib"
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
)
......@@ -345,11 +376,41 @@ if [[ "$OSTYPE" =~ "darwin" ]]; then
XCODE_PATH=$($XCODE_CMD -p)
DIRS+=("$XCODE_PATH/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include $XCODE_PATH/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib")
DIRS+=("$XCODE_PATH/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include $XCODE_PATH/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.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
......@@ -369,6 +430,9 @@ if [ "$HAS_LIBPNG" -eq 0 ]; then
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}"
......@@ -468,9 +532,9 @@ VERSION = $VERSION
CC = $CC
CFLAGS = $CFLAGS
LDFLAGS = $LDFLAGS
COCOA_READER = $COCOA_READER
SOLIBSUFFIX = $SOLIBSUFFIX
STATICLIBDEPS = $STATICLIBDEPS
LIQSRCDIR = $LIQSRCDIR
LIQCONFIGUREFLAGS = $(printf "'%s' " "${LIQCONFIGURE[@]}")
" > "$CONFIG"
# Configure static library the same way
cp "$CONFIG" lib/
This diff is collapsed.
Name: pngquant
Version: 2.8.2
Version: 2.12.2
Release: 1%{?dist}
Summary: PNG quantization tool for reducing image file size