A high-performance GPU-accelerated JPEG compressor written in C++ and CUDA.
The tool supports both CPU and GPU paths for comparing compression performance and output quality.
In addition to standard quality-based compression, the tool supports content-aware quality mapping, which preserves visual detail in perceptually important regions while applying stronger compression elsewhere. Optional debug outputs make it easy to inspect and verify how quality is distributed across the image.
This utility demonstrates efficient RGB image compression using CUDA kernels and a custom JPEG scanline writer, with optional CPU comparison for benchmarking and verification.
- GPU-accelerated image compression (CUDA)
- Optional CPU comparison mode (
--compare) - Quality control with
--qualityparameter - Content-aware quality mapping with visual debug outputs
- Simple CLI tool
- Visual Studio 2022 with Desktop Development for C++
- CUDA Toolkit 13.0 or later
- vcpkg (for dependency management)
Prebuilt binaries available on the Releases page
Supports:
- Windows (x64)
-
Clone this repository:
git clone https://github.com/bfalls/img-compressor.git cd img-compressor -
Make sure you have vcpkg installed and integrated with Visual Studio:
C:\vcpkg\vcpkg integrate install
-
Open img-compressor.sln in Visual Studio.
-
Select the desired configuration: Debug x64 (default for development) Release x64 (optimized for speed)
-
Build the project (Ctrl+Shift+B or Build -> Build Solution).
-
Or build on the command line:
msbuild img-compressor.sln "/t:Clean;Build" /p:Configuration=Debug /p:Platform=x64 /m /verbosity:minimal msbuild img-compressor.sln "/t:Clean;Build" /p:Configuration=Release /p:Platform=x64 /m /verbosity:minimal
-
A sample image is included under tests\data\img-test.png. Run the compressor from the project root after building:
.\x64\Debug\img-compressor.exe --input tests\data\img-test.png --output tests\artifacts\out.jpg --quality 85 --compare
If you don't have a GPU it will just use the CPU path. See the timings comparison and don't forget to view the images. Try different quality settings!
[GPU] wrote .\tests\artifacts\out-gpu.jpg in 19.855 ms [CPU] wrote .\tests\artifacts\out-cpu.jpg in 402.399 ms
Baseline (no quality map):
.\x64\Debug\img-compressor.exe --input tests\data\img-test.png --output tests\artifacts\out.jpg --quality 85 --compareThis runs GPU (if available) and CPU, writing out-gpu.jpg / out-cpu.jpg plus a timing/size table.
Content-aware quality map (with debug outputs):
.\x64\Debug\img-compressor.exe --input tests\data\img-test.png --output tests\artifacts\out.jpg --quality 85 --compare --quality-map --quality-map-debug tests\artifactsFlags of interest:
--quality-map: enable saliency-based, per-block coefficient scaling.--quality-map-strength <0..1>: blend amount (default0.6).--quality-map-min-scale/--quality-map-max-scale: bounds for per-block scaling (defaults0.7/1.6).--quality-map-debug <dir>: writesimportance_heatmap.pgmandblock_map.csvto the directory you provide. When combining--compare+--quality-map, debug artifacts auto-drop next to the output if you omit this flag.
The quality-map run outputs GPU/CPU JPEGs (with -gpu/-cpu suffixes), a comparison table (size, time, PSNR vs GPU when applicable), and the saliency heatmap/CSV for inspection.
