0.0
No commit activity in last 3 years
No release in over 3 years
Given an image path/URL and a color in RGB, you get back an image with an overlay on it (with the given color).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.12
~> 10.0
~> 3.0
 Project Readme

ImgOverlay

This is a simple gem that gives you your image back overlay-ed with some color.

What is the point of this gem?

Well, I originally created it because I wanted a fast way to turn image URLs into hero images to use on web-pages. Hero images, have some text on them usually. So that they text is readable, they need to be overlay-ed.

See how the title "The smartest way to manage your data" is on some image that is overlay-ed with a purple color that goes with the sites branding? Thats what this gem does.

Dependencies

The gem depends on ImageMagic to be installed on your computer. It just shells out and runs ImageMagic commands.

Installation

Add this line to your application's Gemfile:

gem 'img_overlay'

And then execute:

$ bundle

Or install it yourself as:

$ gem install img_overlay

Usage

Add the gem to your gem file or install it via the command line as shown in the installation section.

To use this, you just have to specify all the info in the form of a hash. There are 3 hashes that are needed:

  1. Input Hash: This can have the URL of the image / file path of the image
  2. Color Hash: The RGB values of the color for the overlay & the opacity of the overlay layer
  3. Output Hash: A location where the final output image needs to be stored

Example

require 'img_overlay'

include ImgOverlay

success = make_image_with_overlay(
    input: {
      url: "http://craftypioneer.com/wp-content/uploads/2016/01/businessMeeting.jpg" 
    },
    color: {
        r: 0,
        g: 0,
        b: 0,
        opacity: 0.6
    },
    output: {
       path: '/Users/khojbadami/test.jpg'
    }
)

That's it. It all works, you will get a true or a false.

Fixed Bug

There was a bug in version 0.1.0 where it would not reuturn false if it failed to make the image. Fixed that bug with an update to version 0.1.1

Testing

This gem needs more tests and development around validating user input and giving helpful error messages. Just now, it will simply fail. It needs better feedback for users when the inputs are not right. It also needs better error messages when the inputs are funny.

License

The gem is available as open source under the terms of the MIT License.