Skip to content

Commit

Permalink
Add configurable limits for memory, map, and disk in IiifPrint
Browse files Browse the repository at this point in the history
- Added `memory_limit`, `map_limit`, and `disk_limit` options to IiifPrint::Configuration with attr_accessors
- Updated iiif_print initializer to allow optional configuration of these limits
- Added example comments in configuration.rb for setting limits
- Ensures ImageMagick falls back to imagemagic-6-policy.xml limits if values are left unset

This change provides flexibility for resource management in image processing while retaining default behaviors.
  • Loading branch information
Shana Moore committed Nov 7, 2024
1 parent 73ac600 commit bda3097
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
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
8 changes: 4 additions & 4 deletions lib/iiif_print/image_tool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ def im_identify_geometry(lines)

# @return [Array<String>] lines of output from imagemagick `identify`
def im_identify
memory_limit = ENV["IM_MEMORY_LIMIT"]
map_limit = ENV["IM_MAP_LIMIT"]
disk_limit = ENV["IM_DISK_LIMIT"]
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?
Expand Down

0 comments on commit bda3097

Please sign in to comment.