Coder Social home page Coder Social logo

pyedgeon's Introduction

pyedgeon

Simple class to generate circular images that read a short phrase when held at eye level, nearly edge-on. PIL is used for image processing.

The code has basic functionality and some user-editable settings like choosing the path to the font file, size of the output image, and what words to write.

It's a lot easier to view the generated images on a mobile or tablet where you can freely orient the device in space. After running the script, you should obtain an image like this:

alt text

The solution to the above illusion is "NPR COOL DAD ROCK" ;)

Usage

Proudly now a pip package!

pip install pyedgeon

After downloding, include in a script

from pyedgeon import Pyedgeon

test = Pyedgeon(illusion_text="hello world")

test.create()

This will create a default image in the cwd. A full list of options with defaults follows:

test = Pyedgeon(illusion_text="hello world", font_path = "DejaVuSans-ExtraLight.ttf", num_rotations = 6, file_path = "", file_name = None, file_ext = ".png", text_color = (0, 0, 0), background_color = (255, 255, 255), img_side = 1024, charmax = 22, crop_width_x = 14, crop_width_y = 15, darkness_threshold = 116, upper_case = True)

illusion_text: Text in the button. Will be automatically casted to upper-case by default.

num_rotations: The number of times the text will be stamped around the circle, at intervals of 180/num_rotations degrees.

file_path: The path to write out the file

file_name: the filename before the extension of the utput file. Defaults to illusion_text

file_ext: File format for output, in string, ".xyz" format

text_color: 3-tuple of values 0:255 for controlling the text color

background_color: 3-tuple of values 0:255 for controlling the background color

img_side: Size of image in pixels, per side.

charmax: Maximum character limit. Works best when around 22 for many fonts, but may need to be changed if you are using uncommon or very narrow fonts.

crop_width_x: Adjusts overlap of bounding box and image on the left and right edges of text.

crop_width_y: Adjusts overlap of bounding box and image on the top and bottom edges of text.

darkness_threshold: Threshold for step function which transforms gray pixels to black or white during image creation.

filepath: (use a forward slash to end the string) a folder location to save the file

upper_case: set to False to use mixed or lower-case characters.

Outputs

The .create() method will save a file to the location:

  • self.filepath/self.file_name+self.file_ext

Meanwhile, self.full_image has the image in memory.

Be sure to check out pyedgeon-service for a fun app that uses this API!

pyedgeon's People

Contributors

abehmiel avatar

Stargazers

Miriam Kosik avatar Günther Jena avatar Brennen Raimer avatar James Beardsley avatar Pankesh Bamotra avatar Nate Murray avatar Nicolas Seriot avatar Stephen Peterson avatar

Watchers

James Cloos 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.