Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i876 - Make memory, map, and disk limits in im_identify configurable #375

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/iiif_print/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ class Configuration
attr_writer :after_create_fileset_handler

attr_writer :ingest_queue_name

# Example settings in the initializer:
# config.memory_limit = "512MiB" # Limit for memory usage
# config.map_limit = "1GiB" # Limit for map usage
# config.disk_limit = "20KP" # Limit for disk usage
attr_accessor :memory_limit, :map_limit, :disk_limit
##
# @return [Symbol, Proc]
def ingest_queue_name
Expand Down
13 changes: 12 additions & 1 deletion lib/iiif_print/image_tool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,18 @@ def im_identify_geometry(lines)

# @return [Array<String>] lines of output from imagemagick `identify`
def im_identify
cmd = "identify -limit memory 8GiB -limit map 16GiB -limit disk 50GiB -format 'Geometry: %G\nDepth: %[bit-depth]\nColorspace: %[colorspace]\nAlpha: %A\nMIME type: %m\n' #{path}"
memory_limit = IiifPrint.config.memory_limit
map_limit = IiifPrint.config.map_limit
disk_limit = IiifPrint.config.disk_limit

cmd = "identify"

cmd += " -limit memory #{memory_limit}" if memory_limit.present?
cmd += " -limit map #{map_limit}" if map_limit.present?
cmd += " -limit disk #{disk_limit}" if disk_limit.present?

cmd += " -format 'Geometry: %G\nDepth: %[bit-depth]\nColorspace: %[colorspace]\nAlpha: %A\nMIME type: %m\n' #{path}"

output, status = Open3.capture2(cmd)
Rails.logger.info "Identify command output: #{output}"
Rails.logger.info "Identify command status: #{status}"
Expand Down
Loading