Skip to content

Commit

Permalink
Merge pull request #67 from performant-software/feature/archnet1216_i…
Browse files Browse the repository at this point in the history
…mage_colors

Archnet #1216 - Image colors
  • Loading branch information
dleadbetter authored Oct 28, 2024
2 parents adf7524 + 6adcaab commit 0323942
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/services/images/convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def self.to_tiff(file)
convert << 'jpeg'
convert << '-alpha'
convert << 'remove'
convert << '-colorspace'
convert << 'sRGB'
convert << "ptif:#{output_path}"
convert.call

Expand Down
27 changes: 27 additions & 0 deletions lib/tasks/iiif.rake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,33 @@ namespace :iiif do
end
end

desc ''
task convert_images_by_colorspace: :environment do
# Parse the arguments
options = {}

opt_parser = OptionParser.new do |opts|
opts.banner = 'Usage: rake iiif:convert_images_by_colorspace [options]'
opts.on('-c', '--colorspace ARG', 'Image colorspace') { |colorspace| options[:colorspace] = colorspace }
end

args = opt_parser.order!(ARGV) {}
opt_parser.parse!(args)

if options[:colorspace].blank?
puts 'Please specify a colorspace...'
exit 0
end

query = Resource.where("(exif::json)->>'colorspace' = ?", options[:colorspace])

query.in_batches do |resources|
resources.pluck(:id).each do |resource_id|
ConvertImageJob.perform_later(resource_id)
end
end
end

desc 'Converts the source images to pyramidal TIFFs for resources by the specified MIME type'
task convert_images_by_type: :environment do
# Parse the arguments
Expand Down

0 comments on commit 0323942

Please sign in to comment.