Skip to content

Instantly share code, notes, and snippets.

@linuxenko
Created March 25, 2016 18:22
Show Gist options
  • Select an option

  • Save linuxenko/f2411aefaece1aa64360 to your computer and use it in GitHub Desktop.

Select an option

Save linuxenko/f2411aefaece1aa64360 to your computer and use it in GitHub Desktop.
Rextract.js Demo
<canvas id="example" width="346" height="361"></canvas>
<a href="https://github.com/linuxenko/rextract.js" target="_blank"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>

Rextract.js Demo

Rextract JS is an image Region Extraction library. HTML5 based image processing library which helps automatically detect regions of the image to extract.

A Pen by Svetlana Linuxenko on CodePen.

License.

(function() {
let ctx = document.getElementById('example').getContext('2d');
let image = document.createElement('img');
image.crossOrigin = 'anonymous';
image.src = 'https://rawgit.com/linuxenko/linuxenko.github.io/master/showcase/peter/petr.png';
image.onload = () => {
ctx.drawImage(image, 0, 0);
new Rextract(image).detectAll().forEach( i => {
ctx.strokeRect(i.x, i.y, i.w, i.h);
});
}
})();
<script src="https://npmcdn.com/rextract.js@0.2.2/dist/rextract.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment