Class: JekyllImgFlow::Tags::CropTag
- Defined in:
- lib/jekyll-imgflow/tags/crop_tag.rb
Overview
Crop tag - processes image cropping (validation handled by Parser)
Instance Method Summary collapse
Methods inherited from BaseTag
Constructor Details
This class inherits a constructor from JekyllImgFlow::Tags::BaseTag
Instance Method Details
#process(input_path, output_path, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/jekyll-imgflow/tags/crop_tag.rb', line 9 def process(input_path, output_path, = {}) ensure_output_dir(output_path) # Validate that crop information is provided ratio = [:ratio] || [:aspect_ratio] has_pixel_crop = [:width] || [:height] unless ratio || has_pixel_crop raise ArgumentError, "Crop operation requires ratio or at least one dimension (width or height)" end if ratio # Handle aspect ratio cropping (e.g., "16:9", "4:3") validate_ratio(ratio) handle_aspect_ratio_crop(input_path, output_path, ratio, ) else # Handle pixel-based cropping with flexible dimensions validate_positive_integer([:width], "width") if [:width] validate_positive_integer([:height], "height") if [:height] validate_positive_integer([:x], "x") if [:x] validate_positive_integer([:y], "y") if [:y] handle_pixel_crop(input_path, output_path, ) end @provider.execute(input_path, output_path) end |