Git Product home page Git Product logo

blurrer's Introduction

Blurrer

I like 8 bit art, and I wanted to make an easy method for pixellating existing images from the command line.

With this script, you can:

  • Convert images of common filetypes to pixellated versions
  • Specify the size of the pixels to be used in the resulting image

What it does

The input image is divided into squares matching the input final pixel size.

The average color of each of those squares is then calculated by averaging each of the RBGA values from the member pixels.

A new image is then constructed of squares matching the input final pixel size, with the color of those squares being set to the calculated average color of the original pixels in that area.

How we deal with remainders

Pixellated art should end up with an whole number of vertical and horizontal pixels. In order to keep the result looking correct, the input images are cropped to the largest even multiple of the specified final pixel size.

An example

Here's a 700x700 image of a Mario Mushroom from Wikipedia:

Mario Mushroom

The goal is to pixellate this photo, with the resulting picture having square 35x35 pixels.

To make this happen, the following command line arguments are used:

python blur.py blur test.png 35

The resulting image was pixellated, with the end result composed of 35x35 pixel squares:

Blurred Mario Mushroom

Another example (with cropping being necessary)

If a specified pixel size isn't evenly divisible into the input image's dimensions, then the result needs to be cropped so no partial pixels are present.

As an example, again relying on the Mario mushroom picture, we will specify a pixel size of 60. This isn't evenly divisible, so cropping will occur to the nearest full pixel of that size.

python blur.py blur test.png 60

The resulting image was pixellated, with the end result composed of 60x60 pixel squares, and has been cropped (it's now 11 by 8 "pixels")

Blurred Mario Mushroom

As of now, cropping will only occur from the right and bottom edges of a photo (note that the 60x60 blurred image seems shifted to the bottom right)

To-dos:

  • Correct shifting in cropped images (crop evenly from the center)
  • Add support for other filetypes
  • Add support for animated GIF blurring and recomposition

blurrer's People

Contributors

jordanwdunne avatar

Stargazers

Ivan avatar Soham avatar

Watchers

 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.