Skip to content
Open
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
8 changes: 8 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
BasedOnStyle: Google
AccessModifierOffset: -4
AllowShortFunctionsOnASingleLine: Inline
BinPackArguments: false
BinPackParameters: false
ColumnLimit: 120
IndentWidth: 4
SpacesBeforeTrailingComments: 1
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: CI

on:
push:
branches: [master]
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install libpng
run: sudo apt-get update && sudo apt-get install -y libpng-dev
- name: Check formatting
run: clang-format --dry-run --Werror include/mapbox/*.hpp test/test.cpp test/bench.cpp test/png_decode.hpp
- run: cmake -B build -DCMAKE_BUILD_TYPE=Release
- run: cmake --build build
- run: ctest --test-dir build --output-on-failure
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

37 changes: 37 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
cmake_minimum_required(VERSION 3.15)

project(pixelmatch
VERSION 1.0.0
DESCRIPTION "C++ port of pixelmatch, a pixel-level image comparison library"
LANGUAGES CXX
)

add_library(pixelmatch INTERFACE)
add_library(mapbox::pixelmatch ALIAS pixelmatch)

target_include_directories(pixelmatch INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

target_compile_features(pixelmatch INTERFACE cxx_std_11)

if(PROJECT_IS_TOP_LEVEL)
enable_testing()
find_package(PNG REQUIRED)

add_executable(test_pixelmatch test/test.cpp)
target_link_libraries(test_pixelmatch PRIVATE pixelmatch PNG::PNG)
target_compile_options(test_pixelmatch PRIVATE -Wall -Wextra -Wshadow)
add_test(NAME pixelmatch
COMMAND test_pixelmatch
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

add_executable(bench_pixelmatch test/bench.cpp)
target_link_libraries(bench_pixelmatch PRIVATE pixelmatch PNG::PNG)
target_compile_options(bench_pixelmatch PRIVATE -Wall -Wextra)
endif()

include(GNUInstallDirs)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015, Mapbox
Copyright (c) 2026, Mapbox

Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
Expand Down
17 changes: 0 additions & 17 deletions Makefile

This file was deleted.

32 changes: 23 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
## pixelmatch-cpp

[![Build Status](https://travis-ci.org/mapbox/pixelmatch-cpp.svg?branch=master)](https://travis-ci.org/mapbox/pixelmatch-cpp)

A C++ port of [pixelmatch](https://github.com/mapbox/pixelmatch), the smallest, simplest and fastest JavaScript pixel-level image comparison library.

This is a header-only library; add `include/` to your include path, use it as a CMake subdirectory, or install it and link against `mapbox::pixelmatch`.

## Building & testing

Requires CMake 3.15+ and a C++11 compiler.

```bash
cmake -B build
cmake --build build
ctest --test-dir build --output-on-failure
```

To generate an Xcode project: `cmake -B build -G Xcode && open build/pixelmatch.xcodeproj`.

## API

```cpp
namespace mapbox {

uint64_t pixelmatch(const uint8_t* img1,
const uint8_t* img2,
std::size_t width,
std::size_t height,
uint8_t* output = nullptr,
double threshold = 0.1,
bool includeAA = false);
uint64_t pixelmatch(
const uint8_t* img1,
const uint8_t* img2,
std::size_t width,
std::size_t height,
uint8_t* output = nullptr,
double threshold = 0.1,
bool includeAA = false
);

}
```
Expand Down
1 change: 0 additions & 1 deletion deps/gyp/.gitignore

This file was deleted.

27 changes: 0 additions & 27 deletions deps/gyp/LICENSE

This file was deleted.

1 change: 0 additions & 1 deletion deps/gyp/OWNERS

This file was deleted.

118 changes: 0 additions & 118 deletions deps/gyp/PRESUBMIT.py

This file was deleted.

10 changes: 0 additions & 10 deletions deps/gyp/codereview.settings

This file was deleted.

8 changes: 0 additions & 8 deletions deps/gyp/gyp

This file was deleted.

5 changes: 0 additions & 5 deletions deps/gyp/gyp.bat

This file was deleted.

18 changes: 0 additions & 18 deletions deps/gyp/gyp_main.py

This file was deleted.

Loading
Loading