This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
OperatorImageOverlay
image_overlay(image_overlay_path, options = {})
Adds an overlay to the base image. It’s useful for things like attaching a logo, watermark, or even a border to the image. It will work best with a 24-bit PNG with alpha channel since it will properly deal with partial transparency.
image_overlay_path
The path, relative toRAILS_ROOTwhere the image you want superimposed can be found.
Use the following keys in the options hash:
:size
The size of the overlayed image, as"123x456"or[123, 456]. By default the overlay is not resized before compositing. Use this option if you want to resize the overlay, perhaps to have a small logo on thumbnails and a big logo on full size images. Other than just numerical dimensions, the size parameter takes 2 special values:scale_to_fitand:stretch_to_fit.:scale_to_fitwill make the overlay fit as much as it can inside the image without changing the aspect ratio.:stretch_to_fitwill make the overlay the exact same size as the image but with a distorted aspect ratio to make it fit.:stretch_to_fitis designed to add border to images.
:alignment
A symbol that tells Fleximage where to put the overlay. Can be any of the following::center,:top,:top_right,:right,:bottom_right,:bottom,:bottom_left,:left,:top_left. Default is:center.
:offset
The number of pixels to offset the overlay from it’s:alignmentanchor, in"123x456"or[123, 456]format. Useful to give a bit a space between your logo and the edge of the image, for instance. NOTE: Due to some unexpected (buggy?) RMagick behaviour:offsetwill work strangely if:alignmentis set to a non-corner value, such as:topor:center. Using:offsetin these cases will force the overlay into a corner anyway.
:blending
The blending mode governs how the overlay gets composited onto the image. You can get some funky effects with modes like:copy_cyanor:screen. For a full list of blending modes checkout the RMagick documentation. To use a blend mode remove theCompositeOpform the name andunserscorizethe rest. For instance,MultiplyCompositeOpbecomes:multiply, andCopyBlackCompositeOpbecomes:copy_black.
Example
@photo.operate do |image|
image.image_overlay('images/my_logo_with_alpha.png',
:size => '25x25',
:alignment => :top_right,
:blending => :screen
)
end






