kornelski / pngquant

Lossy PNG compressor — pngquant command based on libimagequant library
https://pngquant.org
Other
5.19k stars 483 forks source link

[Feature Request] Updating Windows binary version on pngquant.org #384

Closed kubinka0505 closed 2 years ago

kubinka0505 commented 2 years ago

As of today, the latest version of pngquant for Windows 2.14.1.


I've tried to compile the program manually using Google Colab, basing on the official install instructions, but the result was unopenable file with no extension and size around 4 MB - I've probably forget something.

%cd /content/
!rm -rf /pngquant/
!apt-get install cargo
!git clone -b msvc --recursive https://github.com/kornelski/pngquant.git
%cd /pngquant/
!cargo build --release --features=sse,lcms2

Can I ask for update of the latest version? ...Especially if #376 fix was maintained and speed and quality improvements were made.

Guest126 commented 2 years ago

Comrade, I build it! You can download here. https://github.com/Guest126/pngquant/releases/tag/2.16.0-patch-1

Guest126 commented 2 years ago

Let me explain what i did.

First, I followed the pngquant Installation instructions and installed Rust and Visual Studio 2019 on Windows 10.

Clone the msvc branch for Windows from the repository.

> git clone -b msvc --recursive https://github.com/kornelski/pngquant.git
Cloning into 'pngquant'...
remote: Enumerating objects: 4746, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (42/42), done.
remote: Total 4746 (delta 28), reused 38 (delta 16), pack-reused 4687
Receiving objects: 100% (4746/4746), 1.76 MiB | 2.80 MiB/s, done.
Resolving deltas: 100% (3121/3121), done.
Submodule 'lib' (https://github.com/ImageOptim/libimagequant.git) registered for path 'lib'
Cloning into 'C:/[censored]/pngquant/lib'...
remote: Enumerating objects: 4277, done.
remote: Counting objects: 100% (152/152), done.
remote: Compressing objects: 100% (87/87), done.
remote: Total 4277 (delta 75), reused 114 (delta 55), pack-reused 4125
Receiving objects: 100% (4277/4277), 898.74 KiB | 7.19 MiB/s, done.
Resolving deltas: 100% (2803/2803), done.
Submodule path 'lib': checked out 'f41ee301ff3a407b16991af3dbe03910919bbdc3'

Build.

> cd pngquant
> cargo build --release
    Updating crates.io index
   Compiling jobserver v0.1.24
   Compiling pkg-config v0.3.22
   Compiling dunce v1.0.2
   Compiling vcpkg v0.2.15
   Compiling libc v0.2.106
   Compiling bytemuck v1.7.2
   Compiling unicode-width v0.1.9
   Compiling glob v0.3.0
   Compiling bitflags v1.3.2
   Compiling cc v1.0.71
   Compiling rgb v0.8.29
   Compiling getopts v0.2.21
   Compiling wild v2.0.4
   Compiling libz-sys v1.1.3
   Compiling imagequant-sys v3.1.0+sys2.16.0 (C:\[censored]\pngquant\lib)
   Compiling libpng-sys v1.1.8
   Compiling lcms2-sys v3.1.9
   Compiling pngquant v2.16.0 (C:\[censored]\pngquant)
warning: msvc-dist/ directory not present. MSVC builds may fail
    Finished release [optimized] target(s) in 23.51s

The executable binary 2.16.0 is compiled. But, this had a issue #376 that have been fixed in 2.15.0.

\pngquant> target/release/pngquant.exe "イメージ.png"
  error: cannot open 繧、繝。繝シ繧ク.png for reading

The file containing Japanese cannot be opened and the file name is garbled. why?

GustJc said,

// Inside static pngquant_error read_image setlocale(LC_ALL, ".65001");

Although, https://github.com/kornelski/pngquant/commit/b4d77c72058b70baef63fa6aa1ba2ad74e2c835d added setlocale() inside the main() function instead of the read_image() function.

In addition, it looks that the main() function is not compiled by the preprocessor.

#ifndef PNGQUANT_NO_MAIN
int main(int argc, char *argv[])

So setlocale() wasn't working. I don't understand the reason for doing this.

There is a compile switch in rust/build.rs.

cc.define("PNGQUANT_NO_MAIN", Some("1"));

When I commented out this line, I got some compilation errors. I gave up fixing the error and undo the changes.

So, I added setlocale() inside the pngquant_main_internal() function (or read_image() function) as GustJc did. I don't know if this is really the right thing to do, but it seems to be working so far.

kubinka0505 commented 2 years ago

Although I don't understand anything - thanks for detailed explanation, I will definitely use this.

However, I will keep this issue opened until the official download link will be updated. Sorry.

God-damnit-all commented 2 years ago

@kornelski Could you please address this? If it's a compilation problem, an earlier comment in this issue has a successfully completed compilation and the person who compiled it explains how it was accomplished.

I just noticed that you remarked elsewhere that you were now using ARM to compile and you've been having trouble. Why not rely on GitHub actions to build the binaries for you?

kornelski commented 2 years ago

Updated