Skip to content

coconauts/image-to-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image to JSON converter

Convert Image bitmaps to JSON using Javascript + Canvas.

This small black/white image

Small sample image

will produce this JSON with all black pixel coordinates:

[
  {"x":1,"y":1},
  {"x":1,"y":2},
  {"x":1,"y":5},
  {"x":2,"y":6},
  {"x":3,"y":6},
  {"x":4,"y":6},
  {"x":5,"y":6},
  {"x":6,"y":1},
  {"x":6,"y":2},
  {"x":6,"y":5}
]

This code was initially created for drawing hundreds of items in a HTML5 game easily.

Map image used in pacman game

See a practical usage of this converter

Demo

Open this URL in your browser:

http://html5.coconauts.net/image-to-json

Drag a small image (up to 200x200) from your computer or drag one of the two images in the page.

The image will be loaded and converted to JSON, you will see all the white / black / other pixels detected.

Click the Download JSON button to download a JSON file with the pixel coordinates.

Or click Preview to see a preview in Canvas of your image. Every pixel will create a black square in the canvas, drag your mouse over the image to watch the pixels disappear.

About

Convert Image bitmaps to JSON using Javascript + Canvas

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published