From 02c3cc4d05252aef90a9226135aaaa7d68fda830 Mon Sep 17 00:00:00 2001 From: Andrew Stevenson Date: Thu, 6 Jun 2024 05:25:08 -0500 Subject: [PATCH] use rot command where possible (#118) --- 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 d3f65d2..b52dbc0 100644 --- a/lib/image_processing/vips.rb +++ b/lib/image_processing/vips.rb @@ -107,7 +107,12 @@ def cover(width, height, **options) # 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