Remove deprecated usage of imagemagick (#37488)

This commit is contained in:
Matt Jankowski
2026-01-22 09:57:19 -05:00
committed by GitHub
parent 3a84b73d80
commit 157d8c0d99
19 changed files with 37 additions and 224 deletions

View File

@@ -19,14 +19,8 @@ module Paperclip
private
def blurhash_params
if Rails.configuration.x.use_vips
image = Vips::Image.thumbnail(@file.path, 100)
[image.width, image.height, image.colourspace(:srgb).extract_band(0, n: 3).to_a.flatten]
else
pixels = convert(':source -depth 8 RGB:-', source: File.expand_path(@file.path)).unpack('C*')
geometry = options.fetch(:file_geometry_parser).from_file(@file)
[geometry.width, geometry.height, pixels]
end
image = Vips::Image.thumbnail(@file.path, 100)
[image.width, image.height, image.colourspace(:srgb).extract_band(0, n: 3).to_a.flatten]
end
end
end

View File

@@ -10,7 +10,7 @@ module Paperclip
BINS = 10
def make
background_palette, foreground_palette = Rails.configuration.x.use_vips ? palettes_from_libvips : palettes_from_imagemagick
background_palette, foreground_palette = palettes_from_libvips
background_color = background_palette.first || foreground_palette.first
foreground_colors = []
@@ -93,17 +93,6 @@ module Paperclip
[background_palette, foreground_palette]
end
def palettes_from_imagemagick
depth = 8
# Determine background palette by getting colors close to the image's edge only
background_palette = palette_from_im_histogram(convert(':source -alpha set -gravity Center -region 75%x75% -fill None -colorize 100% -alpha transparent +region -format %c -colors :quantity -depth :depth histogram:info:', source: File.expand_path(@file.path), quantity: 10, depth: depth), 10)
# Determine foreground palette from the whole image
foreground_palette = palette_from_im_histogram(convert(':source -format %c -colors :quantity -depth :depth histogram:info:', source: File.expand_path(@file.path), quantity: 10, depth: depth), 10)
[background_palette, foreground_palette]
end
def downscaled_image
image = Vips::Image.new_from_file(@file.path, access: :random).thumbnail_image(100)