All Projects → cyberpirate92 → code2img

cyberpirate92 / code2img

Licence: MIT license
Open REST API to create beautiful images of code snippets with 20+ color themes and syntax highlighting support for 10+ languages.

Programming Languages

CSS
56736 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to code2img

Random-Picture
随机图片api
Stars: ✭ 82 (+228%)
Mutual labels:  vercel, vercel-serverless
telepush
可一键部署的Vercel Telegram消息推送机器人
Stars: ✭ 24 (-4%)
Mutual labels:  vercel, vercel-serverless
JiosaavnAPI
Unofficial JioSaavn API Written in Javascript
Stars: ✭ 68 (+172%)
Mutual labels:  vercel, vercel-serverless
personal-puppeteer
A personal web page screenshotting service. Basically, it exposes an API that I can use to generate screenshot of any URL.
Stars: ✭ 19 (-24%)
Mutual labels:  puppeteer, vercel
Qawolf
🐺 Create browser tests 10x faster
Stars: ✭ 2,912 (+11548%)
Mutual labels:  puppeteer, vercel
netlify-cms-oauth-provider-node
A stateless external OAuth provider for netlify-cms with built-in support for Vercel serverless functions
Stars: ✭ 30 (+20%)
Mutual labels:  vercel, vercel-serverless
instagram-get-images
Instagram get images 🌄 (hashtags, account, locations) with puppeteer
Stars: ✭ 69 (+176%)
Mutual labels:  images, puppeteer
linkin
Linkin is a customizable self hosted link tree platform.
Stars: ✭ 62 (+148%)
Mutual labels:  vercel, vercel-serverless
WhatsApp-Bot
🐔 WhatsApp Good Morning
Stars: ✭ 19 (-24%)
Mutual labels:  puppeteer
coderplex-org
Official Website for Coderplex Community. Built with Next.js and deployed on Vercel.
Stars: ✭ 32 (+28%)
Mutual labels:  vercel
after-work.js
[DEPRECATED] CLI for automated tests in web projects.
Stars: ✭ 56 (+124%)
Mutual labels:  puppeteer
image-storage
🌠 Image storage for Nette framework
Stars: ✭ 27 (+8%)
Mutual labels:  images
server-media
This repository collects icons, logos & information about game servers.
Stars: ✭ 29 (+16%)
Mutual labels:  images
puppeteer-autoscroll-down
Handle infinite scroll on websites by puppeteer
Stars: ✭ 40 (+60%)
Mutual labels:  puppeteer
puppeteer-botcheck
🕵‍♂ Bot detection tests for Puppeteer. Hide and seek!
Stars: ✭ 42 (+68%)
Mutual labels:  puppeteer
shallty
Let me suck your fucking trash fansub!
Stars: ✭ 30 (+20%)
Mutual labels:  puppeteer
wp-github-gos
利用 github api 实现的一个存储图片/附件的 wordpress 插件
Stars: ✭ 42 (+68%)
Mutual labels:  images
screenREC
A really simple , ad-free & minimal web based screen recorder 📹
Stars: ✭ 67 (+168%)
Mutual labels:  vercel
LInkedIn-Reverese-Lookup
🔎Search LinkedIn profile by email address📧
Stars: ✭ 20 (-20%)
Mutual labels:  puppeteer
web-ext-deploy
A tool for deploying WebExtensions to multiple stores.
Stars: ✭ 28 (+12%)
Mutual labels:  puppeteer

code2img

PRs Welcome GitHub license Website

A REST API to get pretty images of code snippets with syntax highlighting created using Puppeteer, PrismJS and Vercel.

Image generated with code2img API

Contents

  1. Tech Used
  2. Installation
  3. Using the API
  4. API Documentation
  5. Extensions

Tech Used

Technology Description Link
CSS3 Cascading Style Sheets https://developer.mozilla.org/en-US/docs/Web/CSS
HTML5 Hyper Text Markup Language https://developer.mozilla.org/en-US/docs/Web/HTML
JavaScript High Level, Dynamic, Interpreted Language https://developer.mozilla.org/en-US/docs/Web/JavaScript
NodeJS Open Source Javascript Runtime Environment, Execute Javascript code server side https://nodejs.org/en/
PrismJS Lightweight, extensible syntax highlighter for the web https://prismjs.com
Puppeteer Node library which provides a high-level API to control Chromium over the DevTools protocol https://pptr.dev
Vercel CLI Run Vercel serverless functions locally https://vercel.com/docs/cli

Installation

Running Locally

Make sure Node.js and NPM are installed.

  1. Clone/Download the repository and cd into the project directory
git clone https://github.com/cyberpirate92/code2img.git
cd code2img
  1. Install dependencies
npm install
  1. Run the dev server
NODE_ENV=development vercel dev

The app will now be running at https://localhost:3000

Using the API

Using Postman

Postman is an API client that makes API testing easy.

  1. Download and install Postman from https://www.postman.com/downloads/
  2. Open Postman and import the Postman folder.
  3. In the environment dropdown, select code2img-local if you are running the app locally, otherwise select code2img-prod.
  4. You can find the API operations in the sidebar under code2img.

API Documentation

The API supports the following 3 operations

Get Image

  • HTTP Method: POST
  • Endpoint: /api/to-image
  • Content-Type: text/plain
  • Response Content Type: image/png

Query Parameters

Parameter Required? Data type Description Possible/Example values
theme required string The name of the color theme. All the color themes are from https://github.com/PrismJS/prism-themes a11y-dark, atom-dark, base16-ateliersulphurpool.light, cb, darcula, default, dracula, duotone-dark, duotone-earth, duotone-forest, duotone-light, duotone-sea, duotone-space, ghcolors, hopscotch, material-dark, material-light, material-oceanic, nord, pojoaque, shades-of-purple, synthwave84, vs, vsc-dark-plus, xonokai. Samples for all themes can be found here.
language required string The name of the programming language. This will be used for syntax highlighting. c, css, cpp, go, html, java, javascript, jsx, php, python, rust, typescript
line-numbers optional. Default = false string Show/Hide line numbers. true / false
scale optional. Default = 2 number The device scale factor used to render the image. Higher values will lead to bigger image resolutions and higher file sizes. Default value is 2 Any number in the inclusive range 1-5
background-color optional. Default = yellow string Set a background color. Any valid values used for css background property can be used. Alternatively, If a background image is required, use background-image instead. red, #f00, #ff0000 rgb(255, 0, 0), rgba(255, 0, 0, 0.6), radial-gradient(circle, rgba(63,94,251,1) 0%, rgba(252,70,107,1) 100%)
background-image optional string Set a background image. Any valid image URL can be used. Higher resolution images can cause response to be significantly delayed. https://picsum.photos/1920/1080
show-background optional. Default = true string Show/Hide background. true / false
padding optional. Default = 5 number Amount of padding in the background. Setting padding to 0 is equivalent to setting show-background=false. Any number in the inclusive range 0-15

Description: Given a code snippet in the request body, an image will be returned with the specified theme and language options.

List themes

  • HTTP Method: GET
  • Endpoint: /api/themes
  • Response Content Type: application/json

Description: Get a list of all supported themes.

List languages

  • Http Method: GET
  • Endpoint: /api/languages
  • Response Content Type: application/json

Description: Get a list of all supported languages.

Extensions

Platform Source Download
Google Chrome Extension Source Code Chrome Web Store
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].