From 2f27a4eddd66f298c3d7895d7803f62e432f7a34 Mon Sep 17 00:00:00 2001 From: evazion Date: Tue, 10 Dec 2019 13:57:42 -0600 Subject: [PATCH] image resizer: fix incompatibility with libvips-8.8. In libvips-8.8 the `auto_rotate` option was replaced with `no_rotate`. Using `auto_rotate` in libvips-8.8 fails, so we need a version check here. --- app/logical/danbooru_image_resizer.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/logical/danbooru_image_resizer.rb b/app/logical/danbooru_image_resizer.rb index 82f2581f5..2645f8dff 100644 --- a/app/logical/danbooru_image_resizer.rb +++ b/app/logical/danbooru_image_resizer.rb @@ -5,8 +5,13 @@ module DanbooruImageResizer SRGB_PROFILE = "#{Rails.root}/config/sRGB.icm" # http://jcupitt.github.io/libvips/API/current/libvips-resample.html#vips-thumbnail - THUMBNAIL_OPTIONS = { size: :down, linear: false, auto_rotate: false, export_profile: SRGB_PROFILE, import_profile: SRGB_PROFILE } - CROP_OPTIONS = { linear: false, auto_rotate: false, export_profile: SRGB_PROFILE, import_profile: SRGB_PROFILE, crop: :attention } + if Vips.at_least_libvips?(8, 8) + THUMBNAIL_OPTIONS = { size: :down, linear: false, no_rotate: true, export_profile: SRGB_PROFILE, import_profile: SRGB_PROFILE } + CROP_OPTIONS = { linear: false, no_rotate: true, export_profile: SRGB_PROFILE, import_profile: SRGB_PROFILE, crop: :attention } + else + THUMBNAIL_OPTIONS = { size: :down, linear: false, auto_rotate: false, export_profile: SRGB_PROFILE, import_profile: SRGB_PROFILE } + CROP_OPTIONS = { linear: false, auto_rotate: false, export_profile: SRGB_PROFILE, import_profile: SRGB_PROFILE, crop: :attention } + end # http://jcupitt.github.io/libvips/API/current/VipsForeignSave.html#vips-jpegsave JPEG_OPTIONS = { background: 255, strip: true, interlace: true, optimize_coding: true }