From e4aa8fa474e9e54ec67397772c1d94d50d6dfe2d Mon Sep 17 00:00:00 2001 From: Drew Stevenson Date: Thu, 30 Nov 2023 21:04:39 -0600 Subject: [PATCH] use rot command where possible --- lib/image_processing/vips.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/image_processing/vips.rb b/lib/image_processing/vips.rb index d0e9f45..7a2f6ac 100644 --- a/lib/image_processing/vips.rb +++ b/lib/image_processing/vips.rb @@ -92,7 +92,12 @@ def resize_and_pad(width, height, gravity: "centre", extend: nil, background: ni # Rotates the image by an arbitrary angle. def rotate(degrees, **options) - image.similarity(angle: degrees, **options) + if ([0, 90, 180, 270].include?(degrees) && options.empty?) + rot_command = "rot#{degrees}".to_sym + image.public_send rot_command + else + image.similarity(angle: degrees, **options) + end end # Overlays the specified image over the current one. Supports specifying