CrImage::Util::Border
Border provides methods for adding decorative borders and frames to images.
Class methods
Adds a simple solid border around an image.
Creates a new image with the specified border width and color surrounding the original image. The border is applied uniformly on all sides.
Parameters:
src: The source image to add border towidth: Border width in pixels (must be positive)color: Border color (default: white)
Returns: A new RGBA image with border added
Raises: ArgumentError if width is not positive
Example:
img = CrImage.read("photo.jpg")
framed = img.add_border(20, CrImage::Color::WHITE)
Adds a border with drop shadow effect for depth and dimension.
Creates a professional-looking framed image with a solid border and a blurred drop shadow behind it. The shadow is rendered using Gaussian blur for smooth, realistic appearance.
Parameters:
src: The source imageborder_width: Width of the border in pixels (must be positive)border_color: Color of the border (default: white)shadow_offset: Distance of shadow from border in pixels (default: 8)shadow_blur: Blur radius for shadow softness (default: 10)shadow_color: Color of the shadow (default: semi-transparent black)
Returns: A new RGBA image with border and shadow
Raises: ArgumentError if any dimension parameter is invalid
Example:
img = CrImage.read("photo.jpg")
framed = img.add_border_with_shadow(
border_width: 20,
border_color: CrImage::Color::WHITE,
shadow_offset: 8,
shadow_blur: 10
)
Adds a rounded border with optional drop shadow for premium styling.
Combines rounded corners with a solid border, optionally adding a drop shadow for depth. This creates a modern, card-like appearance commonly used in UI design and photo galleries.
Parameters:
src: The source imageborder_width: Width of the border in pixels (must be positive)corner_radius: Radius of rounded corners in pixels (must be positive)border_color: Color of the border (default: white)shadow: Whether to add drop shadow (default: false)shadow_offset: Shadow offset when enabled (default: 8)shadow_blur: Shadow blur radius when enabled (default: 10)
Returns: A new RGBA image with rounded border and optional shadow
Raises: ArgumentError if dimensions are invalid
Example:
img = CrImage.read("photo.jpg")
framed = img.add_rounded_border(
border_width: 20,
corner_radius: 30,
border_color: CrImage::Color::WHITE
)
Adds rounded corners to an image for a modern, polished look.
Applies circular corner rounding using distance-based masking. Areas outside the rounded corners become transparent. The radius determines how much curvature is applied to each corner.
Parameters:
src: The source imageradius: Corner radius in pixels (must be positive)
Returns: A new RGBA image with rounded corners and transparent background
Raises: ArgumentError if radius is not positive
Example:
img = CrImage.read("photo.jpg")
rounded = img.round_corners(20)