use vips for resizing

This commit is contained in:
Dylan Knutson
2023-08-21 11:16:08 -07:00
parent fb1cc88b6f
commit fcb19bcd02
3 changed files with 8 additions and 10 deletions

View File

@@ -106,7 +106,7 @@ gem "concurrent-ruby-edge", require: "concurrent-edge"
gem "pluck_each"
gem "good_job", "3.17.2"
gem "zstd-ruby"
gem "rszr"
gem "ruby-vips"
gem "composite_primary_keys", "~> 14.0"
gem "pg_query", ">= 2"

View File

@@ -306,10 +306,11 @@ GEM
rspec-mocks (~> 3.11)
rspec-support (~> 3.11)
rspec-support (3.12.0)
rszr (1.3.0)
ruby-prof (1.4.5)
ruby-prof-speedscope (0.3.0)
ruby-prof (~> 1.0)
ruby-vips (2.1.4)
ffi (~> 1.12)
rubyzip (2.3.2)
rufo (0.15.1)
sanitize (6.0.2)
@@ -416,9 +417,9 @@ DEPENDENCIES
react_on_rails
ripcord
rspec-rails
rszr
ruby-prof
ruby-prof-speedscope
ruby-vips
rufo
sanitize
sd_notify

View File

@@ -28,13 +28,10 @@ class BlobsController < ApplicationController
filename = "thumb-#{thumb}-#{sha256}"
filename = filename[..File.extname(filename).length]
filename += ".jpeg"
# file = Tempfile.new("thumb.jpeg", binmode: true)
# file.write(blob_entry.contents)
# file.flush
# image = Rszr::Image.load(file.path)
image = Rszr::Image.load_data(blob_entry.contents)
image.resize!(*thumb_params(thumb))
resized_image_contents = image.save_data(format: :jpg)
width, height = thumb_params(thumb)
image = Vips::Image.thumbnail_buffer(blob_entry.contents, width, height: height)
resized_image_contents = image.jpegsave_buffer
send_data(
resized_image_contents,