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

Open Source Ruby Imaging Library for Read, Write & Resize Images

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

In the world of image processing, efficiency and performance are crucial. Whether you're working on a website that requires on-the-fly image manipulation or processing large volumes of images for your application, the choice of a suitable library can make all the difference. Ruby-Vips, a Ruby gem for the Libvips library, is a powerful tool designed to tackle these challenges. It supports various image formats, including JPEG, PNG, WebP, TIFF, and many more, ensuring that users can handle images in different formats seamlessly.

Ruby-Vips is a Ruby wrapper for the Libvips library, which is known for its speed and memory efficiency. Libvips, short for "VIPS" (the VASARI Image Processing System), is a fast and memory-efficient image processing library that's been around since the early 1980s. Libvips is a C library for image processing that excels in handling large images and can perform a wide range of operations on images with minimal memory overhead. Ruby-Vips allows Ruby developers to harness the full potential of Libvips, making it a valuable addition to your image processing toolkit. It is known for its exceptional performance when working with large images and has become a favorite among developers dealing with image processing tasks at scale.

Ruby-Vips inherits the impressive capabilities of libvips and brings them into the Ruby ecosystem. With its powerful capabilities and efficient image processing, it is an excellent choice for software developers and professionals working with images in their Ruby applications. Whether you're building a website that requires image manipulation, performing scientific image analysis, or processing images in bulk, Ruby-Vips can streamline your workflow and boost performance. Incorporate the library into your image processing projects and harness the speed, efficiency, and versatility it brings to the table.

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