Giter Site home page Giter Site logo

docker-pngifier's Introduction

docker-pngifier

Docker container for rendering various formats to PNGs. Currently has support for:

  • LaTeX
  • ABC music notation
  • Gnuplot

Building

$ docker build -t xtansia/pngifier .

Configuration

The render timeout duration is controlled by the RENDER_TIMEOUT environment variable, which defaults to 10s.

Usage

Run the container

$ docker run -dt --name pngifier xtansia/pngifier

This exposes a very simple HTTP server on port 8080 of the container. Which can be used by POSTing the document to it where the path is the format name, ie. to http://<container_ip>:8080/<latex|abc|gnuplot>.

  • On Success
    • Response is the PNG image
    • Status code is 200
  • On Time Out
    • Response is Timed Out
    • Status code is 408
  • On Failure
    • Response is the error log
    • Status code is 400
$ cat << EOF >hello_world.tex
\documentclass[varwidth,border=1pt]{standalone}
\begin{document}
  Hello World
\end{document}
EOF
$ curl --data-binary @hello_world.tex -o hello_world.png 'http://<container_ip>:8080/latex'

You can also directly execute the 2png commands within the container, piping the document to stdin.

  • On Success
    • PNG image is written to stdout
    • Exit code is 0
  • On Failure
    • Error log is written to stderr
    • Exit code is 1
$ cat << EOF >hello_world.tex
\documentclass[varwidth,border=1pt]
\begin{document}
  Hello World
\end{document}
EOF
$ docker exec -i pngifier latex2png < hello_world.tex > hello_world.png

Security

I make no guarantees as to how secure this container is, so feed it random documents at your own risk. Though to the best of my knowledge the only real risk is reading files within the container through import/include abilities of the various languages.

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.