Skip to content

grimen/placeholder_image

Repository files navigation

PLACEHOLDER_IMAGE

Generate generic placeholder vector images - just like placehold.it, but native.

Dependencies

  • rmagick - for now, plan to optionally replace it with mini_magick when I "get" the API well enough.
  • commander - for command-line support.

Usage

Command-line:

$ placeholder_image 150x100 /tmp/placeholder.png
$ placeholder_image 300x300 /tmp/placeholder.png --text "Hello" --bgcolor "#dddddd" --color "#bbbbbb"

Code:

generator = PlaceholderImage::Generator.new('150x100')
generator.generate!("/tmp/placeholder.png")

generator = PlaceholderImage::Generator.new('300x300', background_color: "#dddddd", text_color: "#bbbbbb")
generator.generate!("/tmp/placeholder.png")

Options

Command-line:

$ placeholder_image help generate

Code:

  • background_color - render background using this color. Default: '#000000'.
  • text_color - render text using this color. Default: '#ffffff'.
  • text - the text rendered centered within the image. Default: '#{WIDTH} x #{HEIGHT}'.

Ruby Versions

No JRuby support, because of RMagick-clash.

Notes

This gem was developed for our own requirements at Merchii, so feel free to send pull-requests with enhancements of any kind (features, bug-fixes, documentation, tests, etc.) to make it better or useful for you as well.

License

Released under the MIT license.

Copyright (c) Jonas Grimfelt, Merchii

About

Generate generic placeholder vector images - just like placehold.it, but native.

Resources

License

Stars

Watchers

Forks

Packages

No packages published