GithubHelp home page GithubHelp logo

sahwar / phixelgator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nathanharper/phixelgator

0.0 2.0 0.0 437 KB

Convert photos to pixel art at the command line.

Python 91.91% Shell 8.09%

phixelgator's Introduction

Phixelgator

Sorry for the dumb title! I couldn't think of anything. This is a command line utility that converts a photo to "pixel art", i.e. a lower resolution version of the same image with a custom color palette.

The idea is that you can specify one of the built-in palettes to use with the -p flag, or you can load a custom palette with the -c flag. The palette files should be in a valid JSON subset consisting of ONE top-level array containing an arbitrary number of arrays that all have EXACTLY three elements, all integers from 0-255. These are representative of RGB values. You can set the pixel width/height of the monochrome blocks to be generated with the -b option. Default is to create 8x8 blocks.

Aside from some basic, tangential image manipulation features like auto-cropping and resizing, the main extra feature is the ability to generate custom color palette files with an input image. Run phixelgator with the -g flag to convert the input image into a color palette file that can then be used with the -c flag. It's not recommended that you use palette files created with very complex images, as extremely large color palettes are the biggest bottleneck in performance. If you just want all the original colors of the image available with a more pixelized look, you can just run it without the -p or -c flag.

Installation

I've tested this successfully on Ubuntu Linux, OSX, and Windows. Dependencies are python >= 2.7 and the python imaging library "PIL". It should work with older versions of python as well, but you'll have to install the argparse library separately. This should be enough on mac and linux:
sudo easy_install PIL 
sudo easy_install argparse

On Windows, you can just get the installers from the site or whatever people do on Windows :P

Once that stuff is done, checkout the repo, and make sure it's executable:

git clone https://github.com/nathanharper/phixelgator.git
cd phixelgator
chmod +x phixelgator.py
./phixelgator.py -h

That's it! The last line in there should print the help info, which should be very up-to-date. You can also check out the bash scripts in the "tests" directory if you want to see some examples.

Examples

Here's a before and after of my cat using the Atari 2600 color palette.

Then you do a little... phixelgator.py -b4 -p atari2600 ernie.jpg atari2600.png

And voila!

Here are the other default palettes.

Apple II

`phixelgator.py -b4 -p appleii ernie.jpg appleii.png`

Commodore 64

`phixelgator.py -b4 -p commodore64 ernie.jpg commodore64.png`

Contra

`phixelgator.py -b4 -p contra ernie.jpg contra.png`

Gameboy

`phixelgator.py -b4 -p gameboy ernie.jpg gameboy.png`

Grayscale

`phixelgator.py -b4 -p grayscale ernie.jpg grayscale.png`

Hyrule

`phixelgator.py -b4 -p hyrule ernie.jpg hyrule.png`

Intellivision

`phixelgator.py -b4 -p intellivision ernie.jpg intellivision.png`

Kungfu

`phixelgator.py -b4 -p kungfu ernie.jpg kungfu.png`

Super Mario Bros.

`phixelgator.py -b4 -p mario ernie.jpg mario.png`

NES

`phixelgator.py -b4 -p nes ernie.jpg nes.png`

Sega

`phixelgator.py -b4 -p sega ernie.jpg sega.png`

Tetris

`phixelgator.py -b4 -p tetris ernie.jpg tetris.png`

Mileage may vary depending on the palette you used, the colors used in the original image, the size of the original image, and the block size selected. All the samples above are using 4x4 monochrome blocks, but in many cases the default 8 will suffice.

Acknowledgement

This tool is *heavily* inspired by a site (which is now down) that was created by:
John Lee and Ethan Levy

phixelgator's People

Contributors

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