mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
Remove deprecated usage of imagemagick (#37488)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user