Skip to content

Doing conditional processing

Janko Marohnić edited this page Mar 26, 2018 · 2 revisions

With the dynamic chainable API it's very easy to do conditional processing:

pipeline = ImageProcessing::Vips
  .source(image)
  .resize_to_limit(400, 400)

if [".jpeg", ".jpg"].include?(File.extname(image.path).downcase)
  pipeline = pipeline
    .saver(interlace: true) # create only interlaced JPEGs, excluding PNGs
    .sharpen(sigma: 0.5, x1: 2, y2: 10, y3: 20, m1: 0, m2: 3) # sharpen only JPEGs
end

result = pipeline.call
result # processed image
Clone this wiki locally