Giter VIP home page Giter VIP logo

pngquant's Introduction

pngquant 3 CI

pngquant 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.

This is the official pngquant repository. The compression engine is also available as an embeddable library.

Usage

  • batch conversion of multiple files: pngquant *.png
  • Unix-style stdin/stdout chaining: … | pngquant - | …

To further reduce file size, try oxipng, ImageOptim, or zopflipng.

Features

  • 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
  • Configurable quality level
  • automatically finds required number of colors and can skip images which can't be converted with the desired quality
  • Fast, modern code

Options

See pngquant -h for full list.

--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

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

Writes converted file to the given path. When this option is used only single input file is allowed.

--skip-if-larger

Don't write converted files if the conversion isn't worth it.

--speed N

Speed/quality trade-off from 1 (slowest, highest quality, smallest files) to 11 (fastest, less consistent quality, light comperssion). The default is 4. 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

Disables Floyd-Steinberg dithering.

--floyd=0.5

Controls level of dithering (0 = none, 1 = full). Note that the = character is required.

--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).

--strip

Don't copy optional PNG chunks. Metadata is always removed on Mac (when using Cocoa reader).

See man page (man pngquant) for the full list of options.

License

pngquant is dual-licensed:

pngquant's People

Contributors

adamkorcz avatar anthraxx avatar ascorbic avatar bdkjones avatar benkasminbullock avatar chjfth avatar craigbarnes avatar dunn avatar dwbuiten avatar evilebottnawi avatar fornwall avatar futureweb avatar guest126 avatar jaalto avatar jibsen avatar joliss avatar kevinji avatar khavishbhundoo avatar kornelski avatar marcolabreu avatar mdonoughe avatar mfoliveira avatar pdknsk avatar philippec avatar rolftimmermans avatar sergiomb2 avatar swillits avatar toy avatar turboencabulator avatar znerd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pngquant's Issues

drawing is corrupted

Hi

I tested the newest version (pornel-improved-pngquant-1.8.3-108-gf309d1b) to compress drawings and got a bad result.
Test on:
openSUSE 12.1 (x86_64) and on SUSE LINUX 10.1 (i586)

without any further options:
pngquant 20094695E001101.a.png

Best regards
Horst

20094695e001101 a
20094695e001101 a-fs8

Cosmetic issues with 2.0

  1. Unfinished code in libimagequant.c
    LIQ_EXPORT liq_attr* liq_attr_create_with_allocator(void* (_malloc)(size_t), void (_free)(void*))
    {
    ...
    if ((malloc != NULL) != (free != NULL)) return NULL; // either specify both or none
liq_attr *attr = malloc(sizeof(liq_attr));

...
If both malloc and free are NULL a problem results (attempt to use NULL function pointer) .
The comment suggests there were plans to handle that case, but they were not implemented.
Not a real problem, just a question mark in code analyser.

  1. Memory leak in pngquant.c
    outname is never free()d.
    Since outname is to be free()d just before the program exit that is not a real problem,
    but since other memory areas are properly deallocated, adding free(outname) just befor "return" from "main" would be nice.

  2. pngquant is not friendly to misuse as a library
    I misused pngquant as a library, renaming its "main" routine and calling it from my code with suitable arguments in argv. The second call fails due to getopt being in need of a reset.
    Consider adding reset of getopt
    optind = 1;
    optreset = 1;
    at the start of the main routine.
    It will not affect the intended use (one run as a standalone program), but will help in my scenario.

Sincerely, Michail

File extension case

pngquant --force --ext=.PNG -- file.PNG

creates a new file called file.PNG.PNG

pngquant --force --ext=.png -- file.png

overwrites file.png

Would it be possible to get --ext=.PNG to overwrite too?

Never-ending ''making histogram..."

pngquant-improved, version 1.4.3.1b (August 2011), by Greg Roelofs, Kornel Lesinski.
Compiled with libpng 1.2.37; using libpng 1.2.37.
Compiled with zlib 1.2.3; using zlib 1.2.3.

Windows XP SP3, Windows 7 SP1

pngquanti.exe -verbose 256 img.png
img.png:
Reading file corrected for gamma 2.2
making histogram...

http://sklabs.ru/tmp/img.png

Compression Size

I am using ImageAlpha but now i want to compress all of the files in batch but ImageAlpha compress more then using terminal command "pngquant 256 *.png" and cant find the other argument that need to send with this like "Dithered" and "Median Cut".
I am using Image Alpha with default settings. please let me know about more arguments.

overwrite (-force, -f) does not have any effect

Hi,

I'm trying to use "improved-pngquant" in my build script. I was looking for a way to overwrite old file with a new (compressed) file.

I found out thru "-h" option that there is a -f option but that does not have any effect and I'm still getting default extension "-fs8".

Is there any work around on that?

Unable to compile on Centos 5.4

Hi,

I am trying to compile your latest version on Centos and am unable to.

[root@sydney pornel-improved-pngquant-0af1c98]# make
gcc -DNDEBUG -Wall -Wno-unknown-pragmas -I. -I../libpng -I../zlib -I/usr/local/include/ -I/usr/include/ -I/usr/X11/include/ -O3 -mtune=native -fearly-inlining -fstrict-aliasing -ffast-math -funroll-loops -fstrict-overflow -fomit-frame-pointer -momit-leaf-frame-pointer -ffinite-math-only -fno-trapping-math -funsafe-loop-optimizations -std=c99 -c -o pngquant.o pngquant.c
cc1: error: unrecognized command line option "-fstrict-overflow"
pngquant.c:1: error: bad value (native) for -mtune= switch
make: *** [pngquant.o] Error 1

I've removed both -mtune and -fstrict-overflow from the makefile, but then when I try to compile, I get a number of errors. The initial one is:

[root@sydney pornel-improved-pngquant-0af1c98]# make
gcc -DNDEBUG -Wall -Wno-unknown-pragmas -I. -I../libpng -I../zlib -I/usr/local/include/ -I/usr/include/ -I/usr/X11/include/ -O3 -fearly-inlining -fstrict-aliasing -ffast-math -funroll-loops -fomit-frame-pointer -momit-leaf-frame-pointer -ffinite-math-only -fno-trapping-math -funsafe-loop-optimizations -std=c99 -c -o pngquant.o pngquant.c
In file included from pngquant.c:56:
rwpng.h:35:57: error: png.h: No such file or directory
In file included from pngquant.c:56:
rwpng.h:60: error: expected specifier-qualifier-list before ‘png_uint_32’
rwpng.h:70: error: expected specifier-qualifier-list before ‘png_uint_32’

I don't know if png.h is supposed to be included in the distribution or it should already be on the system. Can you please let me know what the dependencies are?

I think this is a brilliant program and I'd like to use it.

Thanks,
Tom

pngquant 1.8.3 dithered output looks like not dithered output

Hello,

I have just compiled 1.8.3 (with libpng 1.5.14) and filtered output looks like not filtered output. Results from 1.8.2 version were much better.
See following example, 16 colors.
1.8.2 filtered
1_pngquant_1 8 2_filtered
1.8.3 filtered
3_pngquant_1 8 3_filtered
1.8.2 not filtered
2_pngquant_1 8 2_not_filtered

Have I missed something ?

Have a nice day,

    AiZ

pngquant segmentation fault

pngquant, version 1.6.3 (December 2011), by Greg Roelofs, Kornel Lesinski.
Compiled with libpng 1.2.44; using libpng 1.2.44.
Compiled with zlib 1.2.3.4; using zlib 1.2.3.4.

uname -a:
Linux HOST 2.6.32-5-xen-amd64 #1 SMP Tue Mar 8 00:01:30 UTC 2011 x86_64 GNU/Linux

Program received signal SIGSEGV, Segmentation fault.
0x0000000000406d69 in pam_computeacolorhash (apixels=0x611850, cols=290,
rows=2, gamma=0.45455000000000001, maxacolors=1966080, ignorebits=0,
importance_map=0x611874, acolorsP=0x7fffffffe38c) at pam.c:80
80 union rgb_as_long px = {apixels[row][col]};
(gdb) bt
#0 0x0000000000406d69 in pam_computeacolorhash (apixels=0x611850, cols=290,

rows=2, gamma=0.45455000000000001, maxacolors=1966080, ignorebits=0, 
importance_map=0x611874, acolorsP=0x7fffffffe38c) at pam.c:80

#1 0x0000000000406c41 in pam_computeacolorhist (apixels=0x611850, cols=290,

rows=2, gamma=0.45455000000000001, maxacolors=1966080, ignorebits=0, 
importance_map=0x611870) at pam.c:52

#2 0x00000000004046e1 in histogram (input_image=0x7fffffffea00,

reqcolors=256, speed_tradeoff=3, importance_map=0x611870) at pngquant.c:634

#3 0x0000000000405bc5 in pngquant (input_image=0x7fffffffea00,

output_image=0x7fffffffe4f0, options=0x7fffffffeb00) at pngquant.c:931

#4 0x0000000000402915 in main (argc=3, argv=0x7fffffffec38) at pngquant.c:223

(gdb)

Regards,
Oleg

quality of alpha dithering has degraded from version 1.8.1 to 1.8.3

We are using 1.8.1 on some png and it is doing an amazing job (thank you for the great work), particularly in alpha gradient areas. However, I just downloaded 1.8.3 on my mac, and the results it produced were noticeably worse than that of 1.8.1, and slightly larger file size, at least for the example below.
This is a sample result with 1.8.1
a-christmas-carol-2013-02-27-123019_1_8_1
and this is the result with 1.8.3
a-christmas-carol-2013-02-27-123019_1_8_3
you can see banding in the shadows (which use alpha) in the 1.8.3 output

This is the command line I used:
./pngquant 256 a-christmas-carol-2013-02-27-123019.png

ps- I know, Marley's ghost probably should not be casting a shadow ;-)

Can't compile on RHEL4

I know that this kind of bugs sucks, but I'm stuck. Errors:

pornel-improved-pngquant-93d8bff]$ make
gcc -Wall -Wno-unknown-pragmas -I. -I../libpng -I/usr/local/include/ -I/usr/include/ -I/usr/X11/include/ -DNDEBUG -O3 -fstrict-aliasing -ffast-math -funroll-loops -fomit-frame-pointer -ffinite-math-only -std=c99 -c -o pngquant.o pngquant.c
gcc -Wall -Wno-unknown-pragmas -I. -I../libpng -I/usr/local/include/ -I/usr/include/ -I/usr/X11/include/ -DNDEBUG -O3 -fstrict-aliasing -ffast-math -funroll-loops -fomit-frame-pointer -ffinite-math-only -std=c99 -c -o rwpng.o rwpng.c
gcc -Wall -Wno-unknown-pragmas -I. -I../libpng -I/usr/local/include/ -I/usr/include/ -I/usr/X11/include/ -DNDEBUG -O3 -fstrict-aliasing -ffast-math -funroll-loops -fomit-frame-pointer -ffinite-math-only -std=c99 -c -o pam.o pam.c
gcc -Wall -Wno-unknown-pragmas -I. -I../libpng -I/usr/local/include/ -I/usr/include/ -I/usr/X11/include/ -DNDEBUG -O3 -fstrict-aliasing -ffast-math -funroll-loops -fomit-frame-pointer -ffinite-math-only -std=c99 -c -o mediancut.o mediancut.c
pam.h: In function `colordifference_ch':
mediancut.c:439: error: prior parameter's size depends on 'clrs'
make: *** [mediancut.o] Error 1

I have zlib-devel and libpng-devel installed

$ rpm -qa | grep -e 'zlib' -e 'libpng'
zlib-1.2.1.2-1
zlib-devel-1.2.1.2-1
libpng-1.2.7-1
libpng-devel-1.2.7-1

Full RHEL version

$ cat /etc/redhat-release
Red Hat Enterprise Linux ES release 4 (Nahant Update 1)

Thanks in advance for your help!

1.8.3 fails to compile against libpng 1.6

Original downstream report is here:

https://bugs.gentoo.org/show_bug.cgi?id=464762

Complete build.log is here:

https://bugs.gentoo.org/attachment.cgi?id=344534

And the patch that fixes the conflict is here:

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/media-gfx/pngquant/files/pngquant-1.8.3-libpng16.patch?view=markup

The reason is obvious, libpng 1.6 now has it's own png_image and it's conflicting with the png_image that comes with the rwpng.{h,c}
I expect any software making use of these 2 source files to fail

Fails to compile against vanilla libpng-1.2.44

Reason is in line 371 ../libpng/pngconf.h, solution:

diff --git a/pngquant.c b/pngquant.c
index de1bd81..f895859 100644
--- a/pngquant.c
+++ b/pngquant.c
@@ -52,6 +52,7 @@

include <io.h> /* setmode() */

#endif

+#define PNG_SKIP_SETJMP_CHECK
#include "rwpng.h" /* typedefs, common macros, public prototypes */
#include "pam.h"
#include "mediancut.h"

Washed out color on OS X Mavericks

When I optimized PNGs on Mavericks it really desaturates the colors. I tested this across many different PNGs and it does it to all of them.

screen shot 2013-10-25 at 10 36 37 pm

pngquant does not compile on Debian Lenny

i tried to compile on Debian Lenny which did not work properly:
gcc -std=c99 -O3 -Wall -I. -I../libpng -I../zlib -I/usr/X11/include/ -funroll-loops -fomit-frame-pointer -c -o pam.o pam.c
pam.c: In function ‘pam_hashapixel’:
pam.c:107: error: ‘register_t’ undeclared (first use in this function)
pam.c:107: error: (Each undeclared identifier is reported only once
pam.c:107: error: for each function it appears in.)
pam.c:112: error: expected specifier-qualifier-list before ‘register_t’
pam.c:117: error: ‘struct ’ has no member named ‘l1’
pam.c:117: error: ‘struct ’ has no member named ‘l1’
pam.c:117: error: ‘struct ’ has no member named ‘l2’
make: *** [pam.o] Error 1

if it remove the "-std=c99" it compiles without problems.

After that i got an error while linking though:
gcc -o pngquant pngquant.o rwpng.o pam.o -L../libpng -L../zlib -L/usr/X11/lib/ -L/usr/lib/ -lz -lpng -lm
pngquant.o: In function pngquant': pngquant.c:(.text+0x3a15): undefined reference tomergesort'
pngquant.c:(.text+0x44d0): undefined reference to `mergesort'
collect2: ld returned 1 exit status

i "fixed" this by reverting 911e35b

After this change it compiles fine.

i currently have have:
ii zlib1g 1:1.2.3.3.dfsg-12 compression library - runtime
ii zlib1g-dev 1:1.2.3.3.dfsg-12 compression library - development
ii libpng12-0 1.2.27-2+lenny4 PNG library - runtime
ii libpng12-dev 1.2.27-2+lenny4 PNG library - development
ii gcc-4.3-base 4.3.2-1.1 The GNU Compiler Collection (base package)
installed

i tried to compile the same version on Mac OSX Snow Leopard which works fine without any changes, but there gcc 4.2.1 is used

quality 100 does reduce colors recursively

Using pngquant with quality 100 on the same file, colors can get reduced for a few iterations.

$ pngquant -f --speed 1 --ext .png -v --quality 100- file.png
  made histogram...16 colors found
  mapped image to new colors...MSE=0.002 (Q=100)
  writing 15-color image as file.png

$ pngquant -f --speed 1 --ext .png -v --quality 100- file.png
  made histogram...15 colors found
  mapped image to new colors...MSE=0.022 (Q=100)
  writing 14-color image as file.png

$ pngquant -f --speed 1 --ext .png -v --quality 100- file.png
  made histogram...14 colors found
  mapped image to new colors...MSE=0.000 (Q=100)
  writing 14-color image as file.png

This produces the exact same file, but at lower reported quality.

$ pngquant 14 -f --speed 1 --ext .png -v file.png
  made histogram...16 colors found
  mapped image to new colors...MSE=0.076 (Q=99)
  writing 14-color image as file.png

Compile failure with USE_COCOA flag

Hi,

Firstly, thumbs-up for this util!

I have a problem building from source when using USE_COCOA=1

fatal error: 'CoreGraphics/CoreGraphics.h' file not found

(in v2 there is an extra error in the Makefile)

The solution is to change the import in rwpng_cocoa.m:

-#import <CoreGraphics/CoreGraphics.h>
+#include <ApplicationServices/ApplicationServices.h>

Want a pull request to fix this issue?

p.s. why the colors appear a bit desaturated when using the cocoa build? Something to do with the color profiles? Check here http://dabblet.com/gist/6351700

Large amount of dithering in even colours with pngquant 2.0 (master)

Hello!

When trying the latest version of pngquant (from master), I noticed that in some cases an even colour is being dithered. This does not happen in 1.8.3. It has an extremely negative effect on the image size. In this specific example the image size of the 2.0-optimised version is almost 3 times larger than the 1.8.3-optimised version!

Here is an example of the dithering in 2.0:
example-dither

Here is the result from 1.8.3 (51 KB).
example-fs8-1 8 3

Here is the result from 2.0 (138 KB).
example-fs8-2 0

Here is the original (187 KB).
example-orig

The images were produced with pngquant 256 example.png.

Do you have any idea what the cause is? Is this intended behaviour with 2.0, or is it simply not ready yet?

breaks on 1-bit images

I tried feeding a 1-bit (monochrome) PNG through pngquant. The output was converted to 8-bit and the image was completely corrupt. I can send example files if required.

I assume that pngquant should not increase the palette size of the input PNG.

Partial transparency of pixels not being preserved

Hi, I have noticed that a .png image I am tying to shrink, is maintaining the feathering very well except where color is feathered into transparent in which case the pixels are either coming out fully opaque or fully transparent.

E.g...
https://skydrive.live.com/redir?resid=9F8DE44BC9AC7FD6!120&authkey=!AHEnMrghCFH2YEU

after running: pngquant 256 slide-jigsaw.png

https://skydrive.live.com/redir?resid=9F8DE44BC9AC7FD6!119&authkey=!APCohP1u4LKAYtQ

version 1.7.2
I'm on windows 7 64-bit

Link error on windows

Hello, I compiled the library with GCC from Cygwin on Windows, and add libimagequant.a along with libgcc.a to my VC project, use:
#pragma comment(lib, "./lib/libgcc.a")
#pragma comment(lib, "./lib/libimagequant.a")

liq_attr *attr = liq_attr_create();

At the end of the link I get the following errors:

Linking...
libimagequant.a(libimagequant.o) : error LNK2001: unresolved external symbol __f_pow
libimagequant.a(pam.o) : error LNK2001: unresolved external symbol __f_pow
libimagequant.a(libimagequant.o) : error LNK2001: unresolved external symbol __f_powf
libimagequant.a(mediancut.o) : error LNK2001: unresolved external symbol __f_powf
libimagequant.a(libimagequant.o) : error LNK2001: unresolved external symbol ___getreent
libimagequant.a(libimagequant.o) : error LNK2001: unresolved external symbol _vsnprintf
Debug/RenderSizeTest.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.

how can i fix the issue? thanks!

Suggestion: Make the outfile writable if it does not exist for --output

So I have a program that uses pngquant to process from one directory and output the compressed files to another directory. The new --output flag allowed me to not having to make a copy of the source directory. That's great. But I realize if the destination folder and its subdirectories do not exist before I call pngquant, I'd run into the not-writeable error in write_image. I wonder if there is an easy way to make it work even if the destination isn't there (maybe only do this when it's on both force&&output mode)

script tiny png

hi to all
i want to download script tiny png for website
please help me

very thank

GLIBC_2.11 not found

Hello,

One Grunt plugin is using your tool and on linux-x86-64 it is throwing this error:

/path/to/node_modules/grunt-contrib-imagemin/node_modules/pngquant-bin/vendor/pngquant: /lib64/libc.so.6: version `GLIBC_2.11' not found

Linux is a CI machine. I contacted the admin and here is what he replied:
I ran updates to glibc from our Enterprise Linux distribution but it did not help with this problem. :(

First I wanted to post this as a Grunt plugin issue, but I guess it is more related to the pngquant itself.
Can you give some tips on resolving this?

Linux C CGI port ?

Hello,

First of all, I would like to say that this program is the best png optimizer I have ever found. Thanks a lot for it.

I was wondering if it would be possible for you to create a build for Linux C CGI ?
That would be useful to automatically reduce the size of png files users upload on their website.

I have some advanced knowledge in C, but I can't figure out how the command line flags are working in your program...

Thank you for your time.

Transparent background becomes white

With some images, pngquant appears to poorly align the colormap.

Before: rin_h_strain_close
After: rin_h_strain_close-fs8

They look similar, but the former has a transparent background, and the latter has a white background. This is a major issue for my application, which layers images on top of others.

make fails under centos due to libpng issue with multiple inclusions of setjmp.h

System (CentOS5.2):

Linux 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:34:28 EST 2008 x86_64 x86_64 x86_64 GNU/Linux

These are the libpng-devel versions installed:

libpng-devel.i386 2:1.2.10-7.1.el5_0.1 libpng-devel.x86_64 2:1.2.10-7.1.el5_0.1

Make gives us this output:

gcc -DNDEBUG -O3 -Wall -I. -I../libpng -I../zlib -I/usr/X11/include/ -funroll-loops -fomit-frame-pointer -std=gnu99   -c -o pngquant.o pngquant.c
In file included from /usr/include/png.h:371,
                 from rwpng.h:34,
                 from pngquant.c:46:
/usr/include/pngconf.h:336: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
/usr/include/pngconf.h:337: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'include'
In file included from pngquant.c:49:
nearest.h:8:44: warning: no newline at end of file
pngquant.c: In function 'main':
pngquant.c:222: warning: missing braces around initializer
pngquant.c:222: warning: (near initialization for 'input_image.jmpbuf[0]')
pngquant.c:223: warning: missing braces around initializer
pngquant.c:223: warning: (near initialization for 'output_image.jmpbuf[0]')
make: *** [pngquant.o] Error 1

Seems to be a known problem when compiling libpng with another thing that uses "setjmp.h", the common practice seems to be to patch the pngconf.h under /usr/include... but uh, dunno if I want to do this.
INSTALL of libpng talks about some ways to work around this in code, but I don't have the time to dig into the whole thing right now.

Would be nice if you could comment on this and whether you're planning to "somehow" fix it

Best regards,

Ivo

Compile error on Fedora 18

I posterize.c:369:5: warning: implicit declaration of function 'getopt' [-Wimplicit-function-declaration]
posterize.c:374:48: error: 'optarg' undeclared (first use in this function)
posterize.c:374:48: note: each undeclared identifier is reported only once for each function it appears in
posterize.c:382:16: error: 'optind' undeclared (first use in this function)

I add #include <getopt.h> in posterize.c to fix this problem.

/usr/bin/ld: posterize.o: undefined reference to symbol 'floor@@GLIBC_2.2.5'
/usr/bin/ld: note: 'floor@@GLIBC_2.2.5' is defined in DSO /lib64/libm.so.6 so try adding it to the linker command line
/lib64/libm.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [posterize] Error 1

I add -lm in Makefile to fix this problem.

My compile env is:
Linux localhost.localdomain 3.8.11-200.fc18.x86_64 #1 SMP Wed May 1 19:44:27 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Don't touch images already handled by pngquant

Hi. I'm working on a project where we export (and re-export) lots of images from photoshop (using Slicy). We always want to run these exported pngs through pngquant at some point, but we usually end up doing this in batches, to all pngs in our assets-directory.

Do the images degrade in quality after running pngquant on the same png multiple times? Our build-system relies on checking the md5-hash of all our dependencies (including assets) to repackage / create a new version if files have changed. Is there any way we could run pngquant on all images in a directory, but only process the ones that have not already been compressed using pngquant? By checking if the image has already been paletted / reduced to 8-bit (or some other way)?

Array index out of bounds

Hi!

I came across a situation where there can be an array index out of bounds in nearest_search(). I'd love to send a pull request but I'm not entirely sure what the problem is.

Here is a link to the test image that causes the observed behaviour: http://www.schaik.com/pngsuite/tbwn3p08.png

This happens when running with: pngquant --quality 0-99 256 tbwn3p08.png

And here is some debug information produced with Valgrind:

Invalid read of size 8
   at 0x10000A3A0: nearest_search (nearest.c:228)
   by 0x1000082C9: viter_do_iteration (viter.c:76)
   by 0x100012463: pngquant_quantize (libimagequant.c:1320)
   by 0x10000D45F: liq_quantize_image (libimagequant.c:593)
 Address 0x1000e3f90 is 0 bytes after a block of size 4,576 alloc'd
   at 0x58DB: calloc (in /usr/local/Cellar/valgrind/3.8.1/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
   by 0x1000036E0: pam_colormap (pam.c:238)
   by 0x10000653F: colormap_from_boxes (mediancut.c:417)
   by 0x100006493: mediancut (mediancut.c:400)
   by 0x100011DA9: find_best_palette (libimagequant.c:1239)
   by 0x100012330: pngquant_quantize (libimagequant.c:1305)
   by 0x10000D45F: liq_quantize_image (libimagequant.c:593)

Invalid read of size 8
   at 0x10000A3A4: nearest_search (nearest.c:228)
   by 0x1000082C9: viter_do_iteration (viter.c:76)
   by 0x100012463: pngquant_quantize (libimagequant.c:1320)
   by 0x10000D45F: liq_quantize_image (libimagequant.c:593)
 Address 0x1000e3f98 is 8 bytes after a block of size 4,576 alloc'd
   at 0x58DB: calloc (in /usr/local/Cellar/valgrind/3.8.1/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
   by 0x1000036E0: pam_colormap (pam.c:238)
   by 0x10000653F: colormap_from_boxes (mediancut.c:417)
   by 0x100006493: mediancut (mediancut.c:400)
   by 0x100011DA9: find_best_palette (libimagequant.c:1239)
   by 0x100012330: pngquant_quantize (libimagequant.c:1305)
   by 0x10000D45F: liq_quantize_image (libimagequant.c:593)

Conditional jump or move depends on uninitialised value(s)
   at 0x10000A668: nearest_search (nearest.c:229)
   by 0x1000082C9: viter_do_iteration (viter.c:76)
   by 0x100012463: pngquant_quantize (libimagequant.c:1320)
   by 0x10000D45F: liq_quantize_image (libimagequant.c:593)
 Uninitialised value was created by a heap allocation
   at 0x5237: malloc (in /usr/local/Cellar/valgrind/3.8.1/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
   by 0x1000079CE: mempool_create (mempool.c:29)
   by 0x100009C6C: nearest_init (nearest.c:135)
   by 0x100008231: viter_do_iteration (viter.c:67)
   by 0x100012463: pngquant_quantize (libimagequant.c:1320)
   by 0x10000D45F: liq_quantize_image (libimagequant.c:593)

I've narrowed it down to the fact that eventually in nearest_search() sometimes palette_index_guess is equal to centroids->map->colors, which means the array read is out of bounds. I don't know why this would happen or where to take it from here, though.

Suggestions?

Changes to Makefile for OpenBSD ports

Discovered pngquant on onethingwell.org. Nice work! I would like to submit an
OpenBSD port, but I'd like to see if we can smooth out the build a bit first:

  1. BSD's install doesn't include a -D flag, I think the best thing to do is
    to use @mkdir -p
  2. The install section wasn't installing the man page. It may not be possible to
    write this in a portable way since there is no standard location to install
    man pages.
  3. MAKEFLAGS may be multiple variables, but -$(MAKEFLAGS) seems to expect one parameter
  4. -I. is superfluous
  5. Leave in -I/usr/include/local even if the CFLAGS is defined. Is -I/usr/include ever required?
  6. I think any ports system will want to define such paramets as -Wall and -Wno-unknown-pragmas

All of these are just suggestions, I've posted my current patch for you to
review at
Link to previous patch
https://github.com/jasperla/openbsd-wip/blob/adcbd312f10b5c65772ecf66ad65bb843056e9b6/graphics/pngquant/patches/patch-Makefile

unable to compile on ubuntu

There is no recent Ubuntu package, so I tried to build from source. I got the following error after running "make install"

In file included from pngquant.c:56:0:
rwpng.h:35:57: fatal error: png.h: No such file or directory
compilation terminated.
make: *** [pngquant.o] Error 1

I had a quick look a rwpng.h and it contains

#include "png.h"    /* libpng header; includes zlib.h */

But there is no png.h in the current dir. Sorry, if I'm missing something obvious, I know very little about C

Segfault/crash with PNGs where width and/or height is < 3px

Happens on Linux (compiled by someone else):

pngquant, version 1.7.2 (February 2012), by Greg Roelofs, Kornel Lesinski.
Compiled with SSE2 instructions.
Compiled with libpng 1.2.46; using libpng 1.2.46.
Compiled with zlib 1.2.3.4; using zlib 1.2.3.4.

and Windows (binary from the website):

pngquant, version 1.7.2 (February 2012), by Greg Roelofs, Kornel Lesinski.
Compiled with libpng 1.2.37; using libpng 1.2.37.
Compiled with zlib 1.2.3; using zlib 1.2.3.

I know, I know, why would you want to optimize such small PNGs? Well, they are part of a batch job of 1000s of differently sized PNGs.

Suggestion: Compression on a png picture mixed with text and photo

I am having some ideas when I am compressing a picture mixed with text and photo, but I am not sure how feasible or reasonable it is for pngquant to have a feature for this. Text and photo require different level of quality in compression and most compression tools assume that we are working with only text or photos, so that requires quite a bit of work for me to crop pictures and recompose them after compression, which introduces new performance overheads. I wonder if it is possible for pngquant to determine approximately photos and text in a picture (through a pixel distribution histogram maybe) and compress them with different qualities.

Or if I can come up with bounds for photos and text in the picture, would it be easier for pngquant to selectively apply different compression setting for different bound box in the picture file?

please package with directories PACKAGE-VERSION/

Hi,

Kindly package future release of code inside top level directory:

PACKAGE-VERSION/

So that they can be unpackged nicely:

pngquant-version/
pngquant-version/
...

Unpacking now in wrong directory litters all other files in there.

Thanks

build executable for windows

Hello, I use the pngquant on my css auto sprite tool: joycss. I find that, the old version 1.7.2 has a bug on IE6. The background color will be dark than the origin when a picture is processed by pngquant. When I update to the newest version, the problem is gone.

But, I do not know how to build it at win, build at mac or linux is easy. So, I wish you could help to do that, build the newest version. I think, the unix like system user must know how to update to the newest version, what most needed is win exe file.

thank you, pngqaunt is a great work.

sync Makefile.unx

CFLAGS line: "-std=c99" switch is missing

OBJS line: "pam.o" missing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.