Module: Morandi
- Defined in:
- lib/morandi.rb,
lib/morandi/errors.rb,
lib/morandi/redeye.rb,
lib/morandi/version.rb,
lib/morandi/cairo_ext.rb,
lib/morandi/crop_utils.rb,
lib/morandi/image_operation.rb,
lib/morandi/image_processor.rb,
lib/morandi/profiled_pixbuf.rb,
lib/morandi/srgb_conversion.rb,
lib/morandi/operation/colourify.rb,
lib/morandi/operation/straighten.rb,
lib/morandi/vips_image_processor.rb,
lib/morandi/operation/image_border.rb,
lib/morandi/operation/vips_straighten.rb
Overview
Morandi namespace should contain all the functionality of the gem
Defined Under Namespace
Modules: CairoExt, CropUtils, Operation, RedEye Classes: CorruptImageError, Error, ImageProcessor, ProfiledPixbuf, SrgbConversion, UnknownTypeError, VipsImageProcessor
Constant Summary collapse
- VERSION =
'0.100.0'
Class Method Summary collapse
-
.process(source, options, target_path, local_options = {}) ⇒ Object
The main entry point for the library.
Class Method Details
.process(source, options, target_path, local_options = {}) ⇒ Object
The main entry point for the library
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/morandi.rb', line 50 def process(source, , target_path, = {}) case ['processor'] when 'vips' raise(ArgumentError, 'Requested unsupported Vips operation') unless VipsImageProcessor.supports?(source, ) # Cache saves time in expense of RAM when performing the same processing multiple times # Cache is also created for files based on their names, which can lead to leaking files data, so in terms # of security it feels prudent to disable it. Latest libvips supports "revalidate" option to prevent that risk cache_max = 0 concurrency = 2 # Hardcoding to 2 for now to maintain some balance between resource usage and performance VipsImageProcessor.(cache_max: cache_max, concurrency: concurrency) do VipsImageProcessor.new(source, ).write_to_jpeg(target_path) end else ImageProcessor.new(source, , ).tap(&:result).write_to_jpeg(target_path) end end |