provide default import profile for vipsthumbnail

This commit is contained in:
r888888888
2018-10-24 23:06:12 -07:00
parent 120a3d6402
commit a7dd05fc8f

View File

@@ -4,10 +4,10 @@ module DanbooruImageResizer
# Taken from ArgyllCMS 2.0.0 (see also: https://ninedegreesbelow.com/photography/srgb-profile-comparison.html)
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 }
THUMBNAIL_OPTIONS = { size: :down, linear: false, auto_rotate: false, export_profile: SRGB_PROFILE, import_profile: SRGB_PROFILE }
# http://jcupitt.github.io/libvips/API/current/VipsForeignSave.html#vips-jpegsave
JPEG_OPTIONS = { background: 255, strip: true, interlace: true, optimize_coding: true }
CROP_OPTIONS = { linear: false, auto_rotate: false, export_profile: SRGB_PROFILE, crop: :attention }
CROP_OPTIONS = { linear: false, auto_rotate: false, export_profile: SRGB_PROFILE, import_profile: SRGB_PROFILE, crop: :attention }
# XXX libvips-8.4 on Debian doesn't support the `Vips::Image.thumbnail` method.
# On 8.4 we have to shell out to vipsthumbnail instead. Remove when Debian supports 8.5.
@@ -55,6 +55,7 @@ module DanbooruImageResizer
arguments = [
file.path,
"--eprofile=#{SRGB_PROFILE}",
"--iprofile=#{SRGB_PROFILE}",
"--size=#{target_width}x#{target_height}",
"--format=#{output_file.path}[Q=#{quality},background=255,strip,interlace,optimize_coding]"
]
@@ -77,6 +78,7 @@ module DanbooruImageResizer
arguments = [
file.path,
"--eprofile=#{SRGB_PROFILE}",
"--iprofile=#{SRGB_PROFILE}",
"--smartcrop=attention",
"--size=#{width}x#{height}",
"--format=#{output_file.path}[Q=#{quality},background=255,strip,interlace,optimize_coding]"