HOME
  Security
   Software
    Hardware
  
FPGA
  CPU
   Android
    Raspberry Pi
  
nLite
  Xcode
   etc.
    ALL
  
English Translate 中文翻訳
LINK
BACK
 

[NEW] 2020/03/01

PNG画像を減色してファイルサイズを減らす pngquantアプリを Windows環境で自前でビルドする方法 PNG画像を減色してファイルサイズを減らす pngquantアプリを Windows環境で自前でビルドする方法

(How to build pngquant app. with Windows Visual Studio)

Tags: [Raspberry Pi], [電子工作]





● pngquantを Windows環境で自前でビルドしたいので Visual Studioでコンパイルする

pngquant
 pngquant is a command-line utility and a library for lossy compression of PNG images.
 Current version is 2.12.5

 pngquantは「減色」してファイルサイズを最適化するのでオリジナル画像と比べ「減色による不可逆な劣化」します。

 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.

pngquant Installation
 pngquant Installation
 WIndows環境でのビルド方法。

kornelski / pngquant msvc

Git for Windows Portable (thumbdrive edition)
 32-bit Git for Windows Portable.

git-for-windows/git Git for Windows

 Rust/Cargo
Install Rust

stable installed - rustc 1.42.0 (b8cedc004 2020-03-09)

ビルド環境
・Windows 10 64bit
・Visual Studio 2013
・Windows Rust/Cargo
・Windows Git

● rustup-init.exeを実行して Windows Rust/Cargoをインストールする
Rust is installed now. Great!

To get started you need Cargo's bin directory (%USERPROFILE%.cargo\bin) in your
PATH
environment variable. Future applications will automatically have the
correct environment, but you may need to restart your current shell.

Press the Enter key to continue.

● Windows Gitをインストールする

Git for Windows Portable (thumbdrive edition)
 32-bit Git for Windows Portable.

● Windowsのコマンドラインで pngquant Installationの手順を実行する

pngquant Installation
 pngquant Installation

rem Windows version
git clone -b msvc --recursive https://github.com/kornelski/pngquant.git

cd pngquant
cargo build --release
rem cargo build --release --features=sseしても変わらない

.\target\releaseに pngquant.exeが出来上がる

cargo build --release
    Updating crates.io index
  Downloaded getopts v0.2.21
  Downloaded libc v0.2.67
  Downloaded lcms2-sys v2.4.8
  Downloaded rgb v0.8.16
  Downloaded cc v1.0.50
  Downloaded wild v2.0.2
  Downloaded pkg-config v0.3.17
  Downloaded libpng-sys v1.1.8
  Downloaded unicode-width v0.1.7
  Downloaded glob v0.3.0
  Downloaded jobserver v0.1.21
  Downloaded dunce v0.1.1
  Downloaded dunce v1.0.0
  Downloaded libz-sys v1.0.25
  Downloaded vcpkg v0.2.8
   Compiling jobserver v0.1.21
   Compiling pkg-config v0.3.17
   Compiling vcpkg v0.2.8
   Compiling libc v0.2.67
   Compiling dunce v0.1.1
   Compiling dunce v1.0.0
   Compiling rgb v0.8.16
   Compiling glob v0.3.0
   Compiling unicode-width v0.1.7
   Compiling cc v1.0.50
   Compiling wild v2.0.2
   Compiling getopts v0.2.21
   Compiling libz-sys v1.0.25
   Compiling imagequant-sys v2.12.0 (D:\00_Projects\00_GH\pngquant\lib)
   Compiling libpng-sys v1.1.8
   Compiling lcms2-sys v2.4.8
   Compiling pngquant v2.12.2 (D:\00_Projects\00_GH\pngquant)
warning: msvc-dist/ directory not present. MSVC builds may fail
warning: use of deprecated item 'std::error::Error::description': use the Display impl or to_string()
   --> lib\rust/libimagequant.rs:105:30
    |
105 |         write!(f, "{}", self.description())
    |                              ^^^^^^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default

    Finished release [optimized] target(s) in 31.85s


● Windows版 pngquant.exe 2.12.0 (January 2018)

> pngquant.exe
pngquant, 2.12.0 (January 2018), by Kornel Lesinski, Greg Roelofs.
   Color profiles are supported via Little CMS. Using libpng 1.6.37.

usage:  pngquant [options] [ncolors] -- pngfile [pngfile ...]
        pngquant [options] [ncolors] - >stdout <stdin

options:
  --force           overwrite existing output files (synonym: -f)
  --skip-if-larger  only save converted files if they're smaller than original
  --output file     destination file path to use instead of --ext (synonym: -o)
  --ext new.png     set custom suffix/extension for output filenames
  --quality min-max don't save below min, use fewer colors below max (0-100)
  --speed N         speed/quality trade-off. 1=slow, 3=default, 11=fast & rough
  --nofs            disable Floyd-Steinberg dithering
  --posterize N     output lower-precision color (e.g. for ARGB4444 output)
  --strip           remove optional metadata (default on Mac)
  --verbose         print status messages (synonym: -v)

Quantizes one or more 32-bit RGBA PNGs to 8-bit (or smaller) RGBA-palette.
The output filename is the same as the input name except that
it ends in "-fs8.png", "-or8.png" or your custom extension (unless the
input is stdin, in which case the quantized image will go to stdout).
If you pass the special output path "-" and a single input file, that file
will be processed and the quantized image will go to stdout.
The default behavior if the output file exists is to skip the conversion;
use --force to overwrite. See man page for full list of options.


● git cloneで --recursive指定が無い場合は imagequant-sysが無いエラー

> cargo build --release
    Updating crates.io index
error: failed to load source for a dependency on `imagequant-sys`

Caused by:
  Unable to update D:\00_Projects\00_GH\pngquant-msvc\lib

Caused by:
  failed to read `D:\00_Projects\00_GH\pngquant-msvc\lib\Cargo.toml`

Caused by:
  指定されたファイルが見つかりません。 (os error 2)


● pngquantをラズパイ環境で自前でビルドする場合

Other Rust Installation Methods
 platform armv7-unknown-linux-gnueabihf
 stable (1.42.0)

wget https://static.rust-lang.org/dist/rust-1.42.0-armv7-unknown-linux-gnueabihf.tar.gz
tar xvfz rust-1.42.0-armv7-unknown-linux-gnueabihf.tar.gz
cd rust-1.42.0-armv7-unknown-linux-gnueabihf/
sudo ./install.sh

cd
git clone --recursive https://github.com/kornelski/pngquant.git

cd pngquant/
cargo build --release

./target/release/pngquant
pi@raspberrypi:~/pngquant $ ./target/release/pngquant -V
2.12.6 (July 2019)

pi@raspberrypi:~/pngquant $ ./target/release/pngquant
pngquant, 2.12.6 (July 2019) (Rust), by Kornel Lesinski, Greg Roelofs.

usage:  pngquant [options] [ncolors] -- pngfile [pngfile ...]
        pngquant [options] [ncolors] - >stdout <stdin

options:
  --force           overwrite existing output files (synonym: -f)
  --skip-if-larger  only save converted files if they're smaller than original
  --output file     destination file path to use instead of --ext (synonym: -o)
  --ext new.png     set custom suffix/extension for output filenames
  --quality min-max don't save below min, use fewer colors below max (0-100)
  --speed N         speed/quality trade-off. 1=slow, 4=default, 11=fast & rough
  --nofs            disable Floyd-Steinberg dithering
  --posterize N     output lower-precision color (e.g. for ARGB4444 output)
  --strip           remove optional metadata (default on Mac)
  --verbose         print status messages (synonym: -v)

Quantizes one or more 32-bit RGBA PNGs to 8-bit (or smaller) RGBA-palette.
The output filename is the same as the input name except that
it ends in "-fs8.png", "-or8.png" or your custom extension (unless the
input is stdin, in which case the quantized image will go to stdout).
If you pass the special output path "-" and a single input file, that file
will be processed and the quantized image will go to stdout.
The default behavior if the output file exists is to skip the conversion;
use --force to overwrite. See man page for full list of options.


●その他の画像最適化系アプリ

● PNGOUT
Ken Silverman's Utility Page
 PNGOUT optimizes the size of .PNG files losslessly.
 02/13/2015

PNGOUT [In:{PNG,JPG,GIF,TGA,PCX,BMP}] (Out:PNG) (options...)        Feb 13 2015
by Ken Silverman (http://advsys.net/ken)
PNGOUT optimizes PNG size losslessly using my own deflate algorithm (not Zlib)
With the right options, it can often beat other programs by 5-10%.

PNGOUT [In:{PNG,JPG,GIF,TGA,PCX,BMP}] (Out:PNG) (options...)        Feb 13 2015
by Ken Silverman (http://advsys.net/ken)
PNGOUT optimizes PNG size losslessly using my own deflate algorithm (not Zlib)
With the right options, it can often beat other programs by 5-10%. Options:
   /c# PNG output color: 0=Gray, 2=RGB, 3=Pal, 4=Gray+Alpha, 6=RGB+Alpha
   /f# PNG output filter: 0=none, 1=x, 2=y, 3=x&y, 4=Paeth, 5=mixed, 6=reuse
   /d# Override default bitdepth: 0(min),1,2,4,8 (valid only in /c0,/c3 modes)
   /s# Select strategy. 0:Xtreme(default), 1:Intense, 2:Longest Match,
       3:Huffman Only, 4:Uncompressed
   /b# Block split threshold (lower=more blocks, 0=1 block/file, default=256)
       Use trial&error! Suggested values to try are: 0,128,192,256,512,1024,..
   /n# Exact number of Huffman blocks (overrides /b#)
   /r  Randomized initial tables (good for many trials with same options)
   /i  Use image on windows clipboard as input (specify only output filename)
   /k? 0=Remove optional chunks (default), 1=Keep all
       p=Keep palette indices, s=Keep settings for /c,f,d,b, t=Keep file time
   /k(Chunk,Chunk,..) Preserve only named chunk(s). Example: /kgAMA,bKGD,tEXt
   /v,q,l Verbose,Quiet,List mode (use '-' as filename to specify stdin/stdout)
   /y  Assume Yes at the 'overwrite file?' prompt
   /force  Write file even if bigger.
   /mincodes#  Workaround for buggy decoders. 1:Zlib 1.2.1 bug, 2:buggy mobiles
The 1st filename is the input (except when using /i). If you omit the output
filename, PNGOUT will use the same filename with a .PNG extension. Examples:
   >pngout inlarge.bmp outsmall.png           <- writes outsmall.png
   >pngout duke3d.png /c2 /f3 /b128 /kbKGD /v <- writes duke3d.png if smaller
   >pngout /i clipboard.png                   <- writes clipboard.png
   >for %i in (*.gif) do pngout "%i" /kp      <- convert all GIFs in dir to PNG

For an easy-to-use GUI version, try PNGOUTWin! (http://pngoutwin.com)

● OptiPNG: Advanced PNG Optimizer
OptiPNG: Advanced PNG Optimizer
 OptiPNG is a PNG optimizer that recompresses image files to a smaller size, without losing any information .
 OptiPNG 0.7.7 (stable)

OptiPng.exe -h
Synopsis:
    optipng [options] files ...
Files:
    Image files of type: PNG, BMP, GIF, PNM or TIFF
Basic options:
    -?, -h, -help       show this help
    -o <level>          optimization level (0-7)                [default: 2]
    -v                  run in verbose mode / show copyright and version info
General options:
    -backup, -keep      keep a backup of the modified files
    -clobber            overwrite existing files
    -fix                enable error recovery
    -force              enforce writing of a new output file
    -preserve           preserve file attributes if possible
    -quiet, -silent     run in quiet mode
    -simulate           run in simulation mode
    -out <file>         write output file to <file>
    -dir <directory>    write output file(s) to <directory>
    -log <file>         log messages to <file>
    --                  stop option switch parsing
Optimization options:
    -f <filters>        PNG delta filters (0-5)                 [default: 0,5]
    -i <type>           PNG interlace type (0-1)
    -zc <levels>        zlib compression levels (1-9)           [default: 9]
    -zm <levels>        zlib memory levels (1-9)                [default: 8]
    -zs <strategies>    zlib compression strategies (0-3)       [default: 0-3]
    -zw <size>          zlib window size (256,512,1k,2k,4k,8k,16k,32k)
    -full               produce a full report on IDAT (might reduce speed)
    -nb                 no bit depth reduction
    -nc                 no color type reduction
    -np                 no palette reduction
    -nx                 no reductions
    -nz                 no IDAT recoding
Editing options:
    -snip               cut one image out of multi-image or animation files
    -strip <objects>    strip metadata objects (e.g. "all")
Optimization levels:
    -o0         <=>     -o1 -nx -nz                             (0 or 1 trials)
    -o1         <=>     -zc9 -zm8 -zs0 -f0                      (1 trial)
                (or...) -zc9 -zm8 -zs1 -f5                      (1 trial)
    -o2         <=>     -zc9 -zm8 -zs0-3 -f0,5                  (8 trials)
    -o3         <=>     -zc9 -zm8-9 -zs0-3 -f0,5                (16 trials)
    -o4         <=>     -zc9 -zm8 -zs0-3 -f0-5                  (24 trials)
    -o5         <=>     -zc9 -zm8-9 -zs0-3 -f0-5                (48 trials)
    -o6         <=>     -zc1-9 -zm8 -zs0-3 -f0-5                (120 trials)
    -o7         <=>     -zc1-9 -zm8-9 -zs0-3 -f0-5              (240 trials)
    -o7 -zm1-9  <=>     -zc1-9 -zm1-9 -zs0-3 -f0-5              (1080 trials)
Notes:
    The combination for -o1 is chosen heuristically.
    Exhaustive combinations such as "-o7 -zm1-9" are not generally recommended.
Examples:
    optipng file.png                                            (default speed)
    optipng -o5 file.png                                        (slow)
    optipng -o7 file.png                                        (very slow)


● Zopfli Compression Algorithm

google/zopfli
 Zopfli Compression Algorithm is a compression library programmed in C to perform very good, but slow, deflate or zlib compression.

zopfli for win32 & win64

● WinDDK\7600.16385.1

Windows Driver Kit Version 7.1.0
 Version: 7.1.0
 Date Published: 2/26/2010
 File Name: GRMWDK_EN_7600_1.ISO
 File Size: 619.8 MB

https://download.microsoft.com/download/4/A/2/4A25C7D5-EFBE-4182-B6A9-AE6850409A78/GRMWDK_EN_7600_1.ISO
GRMWDK_EN_7600_1.ISO


● JPEG最適化ツール

● JPEG最適化ツール Mozjpeg
Mozilla JPEG Encoder Project
 MozJPEG reduces file sizes of JPEG images while retaining quality and compatibility with the vast majority of the world's deployed decoders.

cjpeg
djpeg
jpegtran
rdjpgcom
wrjpgcom

NASM
CMake

● jpegoptim
tjko/jpegoptim
 Jpegoptim v1.4.6 - Copyright (C) Timo Kokkonen, 1996-2018. All Rights Reserved.

Timo Kokkonen projects page

● Perceptual JPEG encoder
google/guetzli
 Perceptual JPEG encoder
 Guetzli is a JPEG encoder that aims for excellent compression density at high visual quality. Guetzli-generated images are typically 20-30% smaller than images of equivalent quality generated by libjpeg. Guetzli generates only sequential (nonprogressive) JPEGs due to faster decompression speeds they offer.


●画像比較、単純な数値ではなく視覚的な見え方を考慮した画像の劣化比較判定アプリ

● butteraugli estimates the psychovisual difference between two images

 2つの画像を比較して「見え具合」の差分(劣化具合)を数値化するツール
 psychovisual difference = 心理視覚の違い

google/butteraugli
 butteraugli estimates the psychovisual difference between two images

 butteraugli
 A tool for measuring perceived differences between images

Release v1.0.1 22 Mar 2017



●画像最適化のオンラインサービス

TinyPNG Smart PNG and JPEG compression

 TinyPNG uses smart lossy compression techniques to reduce the file size of your PNG files.

 tinypngは「減色」してファイルサイズを最適化するのでオリジナル画像と比べ「減色による不可逆な劣化」します。

 tinypngは冒頭の「英語」の説明文に明確に「lossy compression」と書いてありますが、一部のブログでは画質が劣化する事に対して「巧妙な罠」と書いてあったりします。
 多分、PNG画像の圧縮仕様が「無劣化の可逆圧縮」である事から、最適化に対しても「PNGだから無条件で無劣化」と言う思い込みで認識しているのでしょうね。(「罠」ではなく「無知」なだけ)
 つーか、普通に「lossy compression(=劣化圧縮)」って書いて有るんだから。。。

TinyJPG Smart PNG and JPEG compression
 TinyJPG reduces the file size of your JPEG images. Every uploaded image is analyzed to apply the best possible JPEG encoding.



Tags: [Raspberry Pi], [電子工作]


[HOME] | [BACK]
リンクフリー(連絡不要、ただしトップページ以外は Web構成の変更で移動する場合があります)
Copyright (c) 2020 FREE WING,Y.Sakamoto
Powered by 猫屋敷工房 & HTML Generator

http://www.neko.ne.jp/~freewing/software/pngquant_build_windows_visual_studio/