Giter Club home page Giter Club logo

plopxy-txt2img's Introduction


##Requirement

##Install

$ php composer.phar install 

##Usage

$ sh txt2img.sh [-s|--style [STYLE]] [-f|--format [FORMAT]] [-o|--output [OUTPUT]] [--fontSizeMax [FONTSIZEMAX]] [-w|--wrap] [--] <text>

OR

$ php application.php text2img [-s|--style [STYLE]] [-f|--format [FORMAT]] [-o|--output [OUTPUT]] [--fontSizeMax [FONTSIZEMAX]] [-w|--wrap] [--] <text>

###text Is the only required param. It can be a simple word, a markdown syntax or a file containing markdown

$ sh txt2img.sh "foo bar" > /tmp/foobar.png

foobar

$ sh txt2imag.sh "*foo*<br>bar" > /tmp/foo_bar_.png

foo_bar_

$ sh txt2imag.sh filename.md > /tmp/finame.md.png

filename.md

###[STYLE] A json array of style parameters

  • font-family : a font familly
  • font : a font file (ttf)
  • font-size : size of the font (if set to "fit", lines will fit the output lenght)
  • color : color of the text
  • background-color : color of the background, default is transparent for PNG and white for JPG
  • background-image : file to be used as a background. url(filename.jpg). the output while have the same size unless max-height or max-width is set.
  • padding : space between image border and text. padding-left, padding-right, padding-to, padding-bottom
  • max-width : width of the output image. if font-size is not set to "fit" the content could be cropped
  • max-height : height of the output image. the content could be cropped.
  • text-align : align content LEFT ,RIGHT, CENTER or JUSTIFY. To use text-align:justify or center you should add the wrap param
  • text-transform : uppercase, lowercase string
  • text-decoration : underline, uperline or line trought

####exemples

$ sh txt2img.sh Plopxy-Txt2img -s '{"color":"purple","font":"doc/font/beyond_the_mountains.ttf","font-size":"60px","padding":"20px"}' -o doc/images/font

Plopxy-Txt2img

$ sh txt2img.sh "best fit<br>multiple lines" -s '{"color":"white","background-color":"red","padding":"10px","text-transform":"uppercase","font-size":"fit","max-width":"200px","font-family":"Helvetica"}' -o doc/images/bestfit

bestfit

###[-w|--wrap]

If set, text will be wrapped, meaning automatic line return preventing word crop. You should use style max-height or background-image in order to fix the width of the output image. **/!\ will not work for text-align : right **

$ sh txt2img.sh test/test2.md -s '{"padding":"10px","font-size":"20","max-width":"400px"}' -o doc/images/wrap.png -w

textwap

$ sh txt2img.sh doc/fauxtxt.md -s '{"max-width":300,"padding":"10px","text-align":"justify"}' -o doc/images/justify.png -w 

justify

$ sh txt2img.sh -v doc/fauxtxt.md -o doc/images/center.png -s '{"max-width":300,"padding":"10px","text-align":"center","background-color":"black","color":"white"}' -w

center

###[vertical-align]

$ sh txt2img.sh -v doc/oneblock.md -o doc/images/valignbottom.png -s '{"max-width":300,"max-height":"300px","padding":"10px","vertical-align":"bottom","background-color":"black","color":"white"}' -w

valignbottom

###[OUTPUT]

Set the output file. If no extension is given, or if the given is not matching format, it will be added. If no output is given, image is returned to standard output.

$ sh txt2img.sh "image png" > /tmp/image.png
$ sh txt2img.sh "image png" -o /tmp/image.png

###[FORMAT]

Default is png, can be set to jpg or gif

$ sh txt2img.sh "test gif" -f gif -o web/images/tmp
Output file: web/images/tmp.gif

###[FONTSIZEMAX]

when using font-size "fit", fontsizemax tell a limit of font-size to be used

$ sh txt2img.sh toto -s '{"padding":"10px","font-size":"fit","max-width":"300px"}' -o ./web/images/test -v --fontSizeMax 80

###[-v|--verbose]

verbose

TO DO // Ideas

  • wrap on text-align right
  • Combine text-decoration
  • Font-size for h1, h2 and h3
  • support list-style for ul
  • neasted UL ?!!

plopxy-txt2img's People

Contributors

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