Sign inSign up

mitonize/mock-image-server

By mitonize

•Updated about 2 years ago

Generate and serve images specifying size, color, texts as URL path and parameters.

Image
1

499

mitonize/mock-image-server repository overview

⁠Mock Image Server

Mock-image-server is an simple image generation server for building website mock-ups.

⁠Run

Start the Docker container by binding port 3000.

docker run -d -p 3000:3000 mitonize/mock-image-server
curl http://localhost:3000/300x200.jpg

⁠Request specification

⁠Path

Foundamental parameters are specified as path component. Path format is as below.

Basic one is simply only width, height and file format like 'png', 'jpg' and so on. The other one clearly specifies the color.

  • /{width}x{height}.{extension} (e.g. /300x200.jpg )
  • /{color hex}/{width}x{height}.{extension} (e.g. /99241c/300x200.png )
path componentdescription
{color hex}Color hex code, No '#' needed.
highest priority color regardless of palette, key.
{width}Image width. range is 1 to 2000.
{height}Image height. range is 1 to 2000.
{extension}File type as 'png', 'jpg', 'svg'
⁠Parameters

Each parameter is optional.

parameterdescriptiondefault value
textText rendered in the image. '%0a' is for newline.generated as "{width}x{height}"
keyColor decision key. Same key is as same color.treat text parameter value as key.
paletteSpecify color palette definition. Palette is defined in palette.yml."neutral" (built in palette)
⁠HTTP Header

Above path and parameter can be specified at the request header X-MockImageServer-Path alternatively. If this header is set, actual path and parameter are ignored.

curl -H X-MockImageServer-Path:/300x200.jpg?text=BBBB&key=KEY1
http://localhost:3000/any/path/to/image.jpg

⁠Examples

http://localhost:3000/300x200.jpg?text=AAAA⁠

These two images are same color since each key is as same. Color is determined automatically from current color palette.

http://localhost:3000/300x200.jpg?text=AAAA&key=KEY1
http://localhost:3000/300x200.jpg?text=BBBB&key=KEY1

To specify color palette, use palette parameter.
These two images below are different color in spite of the same key since palette is not as same. The palette are defined in YAML file. see the source⁠

http://localhost:3000/300x200.jpg?text=AAAA&key=KEY1&palette=pink
http://localhost:3000/300x200.jpg?text=BBBB&key=KEY1&palette=blue

⁠Building the images

The source code that builds this image can be found here⁠

Tag summary

Content type

Image

Digest

sha256:2ea763e93…

Size

153.5 MB

Last updated

over 2 years ago

docker pull mitonize/mock-image-server