1. Products
  2.   Image
  3.   Ruby
  4.   Ruby-Vips
 
  

Free Ruby Imaging Library to Read, Write & Resize Images

Open Source Image Processing Library that allows Software Developers to Generate, Modify, Read, Resize, Watermark and Process Images. 

Ruby-Vips is a high-performance Ruby gem that provides a direct interface to the powerful Libvips image processing library, renowned for its exceptional speed and minimal memory footprint. This efficient Ruby wrapper for Libvips is engineered for developers who require fast, scalable solutions for handling images in their applications, especially when managing large images or performing bulk image processing. It seamlessly supports a wide array of image formats, including JPEG, PNG, WebP, and TIFF, ensuring versatile compatibility. By integrating this Ruby gem for Libvips, developers can perform on-the-fly image manipulation and complex transformations with significantly reduced overhead, making it an indispensable tool for modern image processing in Ruby where performance is critical.

Leveraging the robust foundation of the C library for image processing, Ruby-Vips excels in demanding workflows such as scientific image analysis, high-traffic website optimization, and large-scale media processing. The underlying VASARI Image Processing System (VIPS) has been refined since the 1980s, providing a mature and stable architecture for high-speed operations. This makes Ruby-Vips a favorite among developers for tasks that require both precision and efficiency. Whether you are building a website that needs dynamic image resizing or conducting professional image analysis, this library streamlines your workflow. By incorporating Ruby-Vips into your projects, you harness a proven, memory-conscious tool that delivers the speed, efficiency, and versatility necessary to elevate your application's performance and scalability.

Previous Next

Getting Started with Ruby-Vips

The recommended way to install Ruby-Vips is using RubyGems. Please use the following command for a smooth installation.

Install Ruby-Vips via GitHub

$ gem install ruby-vips

Perform Image Operation via Ruby

The open source Ruby-Vips library allows software developers to work with various types of images and carry different types of operations on them. Using the Ruby library, Software developers can perform a variety of image operations, such as resizing, cropping, rotating, and applying filters. These operations are not only powerful but also highly optimized for performance. The following example shows how software developers can programmatically load and resizes an existing image to a width of 300 pixels, and saves the result using Ruby code.

How to Resize an Existing Image using Ruby API?

require 'vips'
# Open an image
image = Vips::Image.new('input.jpg')
# Resize the image to 300 pixels wide while maintaining the aspect ratio
resized_image = image.thumbnail_image(300)
# Save the resized image
resized_image.write_to_file('output.jpg')

Read & Write Metadata via Ruby

The open source Ruby-Vips library makes it easy for software developers to load, read and write images metadata inside Ruby applications. The library also supports extracting and modifying image metadata with just a couple of lines of Ruby code. You can access details like image width, height, ICC profiles, and EXIF data effortlessly. The following example demonstrates how software developers can read and write metadata from an image using Ruby-Vips library.

How to Read & Write Metadata from an Image using Ruby API?

require 'vips'
# Open an image
image = Vips::Image.new('your_image.jpg')
# Retrieve specific metadata
width = image.get('width')
height = image.get('height')
# Display metadata
puts "Image width: #{width}"
puts "Image height: #{height}"

# Write Metadata from an Image using Ruby-Vips Library?
require 'vips'
# Open an image
image = Vips::Image.new('your_image.jpg')
# Set new metadata
image.set('icc-profile-data', 'new_icc_profile_data')
image.set('exif-data', 'new_exif_data')
# Save the modified image
image.write_to_file('modified_image.jpg')

Fast Processing & Low Memory Footprint

One of the standout features of Ruby-Vips is its exceptional speed. Libvips is designed to be memory-efficient and takes full advantage of modern CPUs, making it ideal for processing large. Memory usage is often a concern when working with large images. The Ruby-Vips minimizes the memory usage through its "lazy" processing model, meaning that it doesn't load the entire image into memory. This results in efficient memory utilization even when working with massive images.

 English