Git Product home page Git Product logo

json-gerbil's Introduction

JSON-GeRBil

A script thrown together for an Image-to-JSON-G-to-Image converter. Though this is a work-in-progress, it should be able to play nicely with other converters that follow the JSON-G spec.

Though you'll likely find that Jsong works better for you if you use only PNG, this script is guaranteed to work with anything ImageMagick is capable of reading, which means no need to waste your time converting to PNG first. :)

C:\Users\Michelle\Desktop\json-gerbil>ruby image-to-json-g.rb 00f.png
Converting to RGBA...
Slicing and dicing...
Determining most common color...
Converting to pixels...
Putting it all together...
Generating the JSON...
Saving your file...
Done. Took 4.790820837020874 seconds.

Prerequesites.

  • The mini_magick gem.
  • The json gem. (Unless you're using the large converter)
  • ImageMagick installed in a place where Ruby can find it (with legacy tools on windows because mini_magick is a dumb)
    • And because ruby is dumb, it doesn't check the current directory if you intend to just place the tools there. Uncomment line 55 of image-to-json-g.rb to fix this, but only if you are running the tools from the same directory.
  • A fuckton of RAM if you plan to process complex images (that is, pictures with lots of colors) because why do you give a fuck about efficiency if you're running this.
    • On that note, if you DO plan to process complex images, then I recommend you try using image-to-json-g-large.rb as this removes the JSON gem and all the hashing, which saves on RAM quite a bit and can help to avoid those pesky out-of-memory errors that the JSON gem can throw.

If you feel the need to run everything within a single directory, these files from a static portable windows download of ImageMagick worked for me for the usual PNG and JPG files:

  • convert.exe
  • identify.exe
  • colors.xml
  • delegates.xml
  • magic.xml
  • These all will need to be placed in the same directory, and line 55 of image-to-json-g.rb will need to be uncommented.

Issues? Questions?

Feel free to open an issue. Please include a log of what happened when you attempted to run the script, including the exception at the end.

TODO

  • Samples to prove this works.
  • Do the other way around (JSON-G to Image)
  • Abstract the main method into something that can be called in an arbitrary process.
  • Layer support.
  • Make a common errors section in this readme.

json-gerbil's People

Contributors

likelakers2 avatar

Watchers

 avatar  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.