Coder Social home page Coder Social logo

pexelmatch's Introduction

Pexelmatch

Pexelmatch is a pure Elixir port of Pixelmatch. We used the same fixtures and tests as Pixelmatch, opting for consistency over correctness. The library is a bit slower, and and doesn't currently offer a binary, but otherwise is feature complete.

We used the same semantics for calling the module. We have not released a binary for it yet. If you'd like to compare images from the command line, just use the Pixelmatch binary.

Installation

If available in Hex, the package can be installed by adding pexelmatch to your list of dependencies in mix.exs:

def deps do
  [
    {:pexelmatch, "~> 0.0.1"}
  ]
end

Usage

You can call the top-level API with &Pexelmatch.run\4 or &Pexelmatch.run\5 (with opts). Pass it image paths, and it will handle the file IO, and compare the images. It will return {:ok, number_of_pixels_changed} and write the diff to the diff path.

  Pexelmatch.run("/path/image.png" "/path/image_2.png"), "./path/diff.png", opts)
  > {:ok, 1}

You can also call &Pexelmatch.Match.apply\3. If will not perform any file I/O, and will return {:ok, number_of_pixels_changed, diff_data}. You are responsible for writing the diff data to disk. In this example we use ExPng for file I/O.

  alias ExPng.Image

  {:ok, img_1} = Image.from_file("/path/img_1.png")
  {:ok, img_2} = Image.from_file("/path/img_2.png")
  {:ok, num_pixels, diff_data} = Match.apply(img_1, img_2, options)
  Image.to_file(diff_data, Path.join(".", "/test/fixtures/temp_diff.png"))

Options work the same way as pixelmatch, but are snake cased.

pexelmatch's People

Contributors

johns10 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.