Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ ipch/
*.cachefile
*.VC.db
*.VC.VC.opendb
guetzli.vcxproj.user
clguetzli/clguetzli.cu.ptx*
1 change: 1 addition & 0 deletions .travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ case "$1" in
"bazel")
case "${TRAVIS_OS_NAME}" in
"linux")
sudo apt-get remove oracle-java9-installer
wget https://github.com/bazelbuild/bazel/releases/download/0.4.5/bazel_0.4.5-linux-x86_64.deb
echo 'b494d0a413e4703b6cd5312403bea4d92246d6425b3be68c9bfbeb8cc4db8a55 bazel_0.4.5-linux-x86_64.deb' | sha256sum -c --strict || exit 1
sudo dpkg -i bazel_0.4.5-linux-x86_64.deb
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ matrix:
packages:
- wget
- libjpeg-progs
- netpbm
- oracle-java8-installer

- os: osx
env: BUILD_SYSTEM=bazel
Expand All @@ -29,6 +31,7 @@ matrix:
- libpng-dev
- pkg-config
- libjpeg-progs
- netpbm

- os: osx
env: BUILD_SYSTEM=make
Expand Down
3 changes: 3 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ cc_library(
"guetzli/*.h",
"guetzli/*.cc",
"guetzli/*.inc",
"clguetzli/*.cpp",
"clguetzli/*.h",
"clguetzli/*.hpp"
],
exclude = ["guetzli/guetzli.cc"],
),
Expand Down
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,59 @@ attempts made.
Please note that JPEG images do not support alpha channel (transparency). If the
input is a PNG with an alpha channel, it will be overlaid on black background
before encoding.

# Extra features

**Note:** Please make sure that you can build guetzli successfully before adding the following features.

## Enable CUDA/OpenCL support

**Note:** Before adding [CUDA](https://developer.nvidia.com/cuda-zone) support, please [check](http://developer.nvidia.com/cuda-gpus) whether your GPU support CUDA or not.

**Note:** If you don't have an NVIDIA card that support CUDA, you can try [OpenCL](https://www.khronos.org/opencl/) instead. You can install any of the OpenCL SDKs, such as [Intel OpenCL SDK](https://software.intel.com/en-us/intel-opencl), [AMD OpenCL SDK](http://developer.amd.com/tools-and-sdks/opencl-zone/), etc.

**Note:** The steps for adding OpenCL support is very similar with adding CUDA support, so the following introduction will be only for CUDA.

### On POSIX systems
1. Follow the [Installation Guide for Linux ](https://developer.nvidia.com/compute/cuda/8.0/Prod2/docs/sidebar/CUDA_Installation_Guide_Linux-pdf) to setup [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit).
2. Edit `premake5.lua`, add `defines { "__USE_OPENCL__", "__USE_CUDA__" }` and `links { "OpenCL", "cuda" }` under `filter "action:gmake"`. Then do `premake5 --os=linux gmake` to update the makefile.
3. Edit `clguetzli/clguetzli.cl` and add `#define __USE_OPENCL__` at first line.
4. Run `make` and expect the binary to be created in `bin/Release/guetzli`.
5. Run `./compile.sh 64` or `./compile.sh 32` to build the 64 or 32 bits [ptx](http://docs.nvidia.com/cuda/parallel-thread-execution) file, and the ptx file will be copied to `bin/Release/clguetzli`.

### On Windows
1. Follow the [Installation Guide for Microsoft Windows](https://developer.nvidia.com/compute/cuda/8.0/Prod2/docs/sidebar/CUDA_Installation_Guide_Windows-pdf) to setup `CUDA Toolkit`.
2. Copy `<vs2015 dir>\VC\bin\amd64\vcvars64.bat` as `<guetzli dir>\vcvars64.bat`
3. Open the Visual Studio project and edit the project `Property Pages` as follows:
* Add `__USE_OPENCL__` and `__USE_CUDA__` to preprocessor definitions.
* Add `OpenCL.lib` and `cuda.lib` to additional dependencies.
* Add `$(CUDA_PATH)\include` to include directories.
* Add `$(CUDA_PATH)\lib\Win32` or `$(CUDA_PATH)\lib\x64` to library directories.
4. Edit `clguetzli/clguetzli.cl` and add `#define __USE_OPENCL__` at first line.
5. Build it.

### Usage
```bash
guetzli [--c|--cuda|--opencl] [other options] original.png output.jpg
guetzli [--c|--cuda|--opencl] [other options] original.jpg output.jpg
```
You can pass a `--c` parameter to enable the procedure optimization or `--cuda` parameter to use the CUDA acceleration or `--opencl` to use the OpenCL acceleration.

If you have any question about CUDA/OpenCL support, please contact strongtu@tencent.com, ianhuang@tencent.com or chriskzhou@tencent.com.

## Enable full JPEG format support
### On POSIX systems
1. Install [libjpeg](http://libjpeg.sourceforge.net/).
If using your operating system
package manager, install development versions of the packages if the
distinction exists.
* On Ubuntu, do `apt-get install libjpeg8-dev`.
* On Fedora, do `dnf install libjpeg-devel`.
* On Arch Linux, do `pacman -S libjpeg`.
* On Alpine Linux, do `apk add libjpeg`.
2. Edit `premake5.lua`, add `defines {"__SUPPORT_FULL_JPEG__"}` and `links { "jpeg" }` under `filter "action:gmake"`. Then do `premake5 --os=linux gmake` to update the makefile.
3. Run `make` and expect the binary to be created in `bin/Release/guetzli`
### On Windows
1. Install `libjpeg-turbo` using vcpkg: `.\vcpkg install libjpeg-turbo`
2. Open the Visual Studio project and add `__SUPPORT_FULL_JPEG__` to preprocessor definitions in the project `Property Pages`.
3. Build it.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ install:
- premake5.exe %TOOLSET%
- git clone https://github.com/Microsoft/vcpkg
- md vcpkg\downloads\nuget-3.5.0
- appveyor DownloadFile https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -FileName %appveyor_build_folder%\vcpkg\downloads\nuget-3.5.0\nuget.exe
- appveyor DownloadFile https://dist.nuget.org/win-x86-commandline/v3.5.0/nuget.exe -FileName %appveyor_build_folder%\vcpkg\downloads\nuget-3.5.0\nuget.exe
- appveyor DownloadFile https://cmake.org/files/v3.8/cmake-3.8.0-rc1-win32-x86.zip -FileName %appveyor_build_folder%\vcpkg\downloads\cmake-3.8.0-rc1-win32-x86.zip
- 7z x %appveyor_build_folder%\vcpkg\downloads\cmake-3.8.0-rc1-win32-x86.zip
- cd vcpkg
Expand Down
Loading