Skip to content

Commit

Permalink
VIPS -> Vips.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpendragon committed Dec 12, 2024
1 parent 0ddfb8f commit 431d7e1
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/derivative_services/default_derivative_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def hocr_derivative_service(change_set_persister = self.change_set_persister)
end

def vips_derivative_service(change_set_persister = self.change_set_persister)
VIPSDerivativeService::Factory.new(change_set_persister: pyramidal_change_set_persister(change_set_persister)).new(id: id)
VipsDerivativeService::Factory.new(change_set_persister: pyramidal_change_set_persister(change_set_persister)).new(id: id)
end

def pyramidal_change_set_persister(change_set_persister)
Expand Down
2 changes: 1 addition & 1 deletion app/derivative_services/scanned_map_derivative_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def thumbnail_derivative_service
end

def vips_derivative_service
VIPSDerivativeService::Factory.new(change_set_persister: pyramidal_change_set_persister(change_set_persister)).new(id: id)
VipsDerivativeService::Factory.new(change_set_persister: pyramidal_change_set_persister(change_set_persister)).new(id: id)
end

def pyramidal_change_set_persister(change_set_persister)
Expand Down
6 changes: 3 additions & 3 deletions app/derivative_services/vips_derivative_service.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true
class VIPSDerivativeService
class VipsDerivativeService
# Pixel width or height at which point it cuts the size in half for
# performance.
REDUCTION_THRESHOLD = 15_000
Expand All @@ -12,7 +12,7 @@ def initialize(change_set_persister:)
end

def new(id:)
VIPSDerivativeService.new(id: id, change_set_persister: change_set_persister)
VipsDerivativeService.new(id: id, change_set_persister: change_set_persister)
end
end

Expand Down Expand Up @@ -110,7 +110,7 @@ def image_from_file(filename)
image =
begin
Vips::Image.new_from_file(filename.to_s)
# If we fail to load a file via VIPS for some reason, load it into vips
# If we fail to load a file via Vips for some reason, load it into vips
# via imagemagick. This will be slower, but fixes images with sub-byte
# byte values. See https://github.com/libvips/libvips/issues/3948
rescue Vips::Error
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/generate_pyramidal_tiff_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class GeneratePyramidalTiffJob < ApplicationJob

def perform(file_set_id)
change_set_persister = Valkyrie::Derivatives::DerivativeService.for(id: file_set_id).change_set_persister
vips_derivative_factory = VIPSDerivativeService::Factory.new(change_set_persister: change_set_persister.with(storage_adapter: Valkyrie::StorageAdapter.find(:pyramidal_derivatives)))
vips_derivative_factory = VipsDerivativeService::Factory.new(change_set_persister: change_set_persister.with(storage_adapter: Valkyrie::StorageAdapter.find(:pyramidal_derivatives)))
vips_derivative_factory.new(id: file_set_id).cleanup_derivatives
vips_derivative_factory.new(id: file_set_id).create_derivatives
rescue Valkyrie::Persistence::ObjectNotFoundError
Expand Down
1 change: 0 additions & 1 deletion config/initializers/inflections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
inflect.acronym "CDL"
inflect.acronym "IIIF"
inflect.acronym "MARC"
inflect.acronym "VIPS"
inflect.acronym "JP2"
inflect.acronym "CSV"
inflect.acronym "MODS"
Expand Down
8 changes: 4 additions & 4 deletions spec/derivative_services/vips_derivative_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
require "rails_helper"
require "valkyrie/derivatives/specs/shared_specs"

RSpec.describe VIPSDerivativeService do
RSpec.describe VipsDerivativeService do
it_behaves_like "a Valkyrie::Derivatives::DerivativeService"

let(:thumbnail) { ::PcdmUse::ThumbnailImage }
let(:derivative_service) do
VIPSDerivativeService::Factory.new(change_set_persister: change_set_persister)
VipsDerivativeService::Factory.new(change_set_persister: change_set_persister)
end
let(:adapter) { Valkyrie::MetadataAdapter.find(:indexing_persister) }
let(:storage_adapter) { Valkyrie.config.storage_adapter }
Expand Down Expand Up @@ -154,7 +154,7 @@

context "tiff source larger than reduction threshold", run_real_derivatives: true do
it "resizes it by half" do
stub_const("VIPSDerivativeService::REDUCTION_THRESHOLD", 1)
stub_const("VipsDerivativeService::REDUCTION_THRESHOLD", 1)
derivative_service.new(id: valid_change_set.id).create_derivatives

reloaded = query_service.find_by(id: valid_resource.id)
Expand All @@ -166,7 +166,7 @@
end
it "uploads it with the appropriate metadata" do
allow(storage_adapter).to receive(:upload).and_call_original
stub_const("VIPSDerivativeService::REDUCTION_THRESHOLD", 1)
stub_const("VipsDerivativeService::REDUCTION_THRESHOLD", 1)
derivative_service.new(id: valid_change_set.id).create_derivatives

expect(storage_adapter).to have_received(:upload).with(file: anything, resource: anything, original_filename: anything, metadata: { "height" => "144", "width" => "100" })
Expand Down

0 comments on commit 431d7e1

Please sign in to comment.