Module: Imagekitio::TransformationUtils Private
- Defined in:
- lib/imagekitio/helpers/transformation_utils.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Transformation utilities for building ImageKit URLs Ported from the Node.js SDK
Constant Summary collapse
- QUERY_TRANSFORMATION_POSITION =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Constants for transformation parsing
:query- PATH_TRANSFORMATION_POSITION =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
:path- CHAIN_TRANSFORM_DELIMITER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
":"- TRANSFORM_DELIMITER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
","- TRANSFORM_KEY_VALUE_DELIMITER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"-"- SUPPORTED_TRANSFORMS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Supported transformations mapping Based on imagekit.io/docs/transformations
{ # Basic sizing & layout "width" => "w", "height" => "h", "aspect_ratio" => "ar", "aspectRatio" => "ar", "background" => "bg", "border" => "b", "crop" => "c", "crop_mode" => "cm", "cropMode" => "cm", "dpr" => "dpr", "focus" => "fo", "quality" => "q", "x" => "x", "x_center" => "xc", "xCenter" => "xc", "y" => "y", "y_" => "y", "y_center" => "yc", "yCenter" => "yc", "format" => "f", "format_" => "f", "video_codec" => "vc", "videoCodec" => "vc", "audio_codec" => "ac", "audioCodec" => "ac", "radius" => "r", "rotation" => "rt", "blur" => "bl", "named" => "n", "default_image" => "di", "defaultImage" => "di", "flip" => "fl", "original" => "orig", "start_offset" => "so", "startOffset" => "so", "end_offset" => "eo", "endOffset" => "eo", "duration" => "du", "streaming_resolutions" => "sr", "streamingResolutions" => "sr", # AI & advanced effects "grayscale" => "e-grayscale", "ai_upscale" => "e-upscale", "aiUpscale" => "e-upscale", "ai_retouch" => "e-retouch", "aiRetouch" => "e-retouch", "ai_variation" => "e-genvar", "aiVariation" => "e-genvar", "ai_drop_shadow" => "e-dropshadow", "aiDropShadow" => "e-dropshadow", "ai_change_background" => "e-changebg", "aiChangeBackground" => "e-changebg", "ai_remove_background" => "e-bgremove", "aiRemoveBackground" => "e-bgremove", "ai_remove_background_external" => "e-removedotbg", "aiRemoveBackgroundExternal" => "e-removedotbg", "ai_edit" => "e-edit", "aiEdit" => "e-edit", "contrast_stretch" => "e-contrast", "contrastStretch" => "e-contrast", "shadow" => "e-shadow", "sharpen" => "e-sharpen", "unsharp_mask" => "e-usm", "unsharpMask" => "e-usm", "gradient" => "e-gradient", "color_replace" => "cr", "colorReplace" => "cr", "colorize" => "e-colorize", "distort" => "e-distort", # Other flags & finishing "progressive" => "pr", "lossless" => "lo", "color_profile" => "cp", "colorProfile" => "cp", "metadata" => "md", "opacity" => "o", "trim" => "t", "zoom" => "z", "page" => "pg", # Text overlay transformations "font_size" => "fs", "fontSize" => "fs", "font_family" => "ff", "fontFamily" => "ff", "font_color" => "co", "fontColor" => "co", "inner_alignment" => "ia", "innerAlignment" => "ia", "padding" => "pa", "alpha" => "al", "typography" => "tg", "line_height" => "lh", "lineHeight" => "lh", # Overlay transformations "layer_mode" => "lm", "layerMode" => "lm", # Subtitles transformations "font_outline" => "fol", "fontOutline" => "fol", "font_shadow" => "fsh", "fontShadow" => "fsh", "color" => "co", # Raw pass-through "raw" => "raw" }.freeze
Class Method Summary collapse
-
.add_as_query_parameter?(options) ⇒ Boolean
private
Check if transformations should be added as query parameter.
-
.get_chain_transform_delimiter ⇒ Object
private
Get chain transform delimiter.
-
.get_transform_delimiter ⇒ Object
private
Get transform delimiter.
-
.get_transform_key(transform) ⇒ Object
private
Get transformation key from supported transforms.
-
.get_transform_key_value_delimiter ⇒ Object
private
Get transform key-value delimiter.
-
.safe_btoa(str) ⇒ Object
private
Safe base64 encoding.
Class Method Details
.add_as_query_parameter?(options) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if transformations should be added as query parameter
133 134 135 136 137 138 |
# File 'lib/imagekitio/helpers/transformation_utils.rb', line 133 def add_as_query_parameter?() [:transformation_position] == QUERY_TRANSFORMATION_POSITION || ["transformation_position"] == QUERY_TRANSFORMATION_POSITION || [:transformation_position] == "query" || ["transformation_position"] == "query" end |
.get_chain_transform_delimiter ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get chain transform delimiter
151 152 153 |
# File 'lib/imagekitio/helpers/transformation_utils.rb', line 151 def get_chain_transform_delimiter CHAIN_TRANSFORM_DELIMITER end |
.get_transform_delimiter ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get transform delimiter
156 157 158 |
# File 'lib/imagekitio/helpers/transformation_utils.rb', line 156 def get_transform_delimiter TRANSFORM_DELIMITER end |
.get_transform_key(transform) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get transformation key from supported transforms
141 142 143 144 145 146 147 148 |
# File 'lib/imagekitio/helpers/transformation_utils.rb', line 141 def get_transform_key(transform) return "" if transform.nil? || transform.to_s.empty? transform_str = transform.to_s SUPPORTED_TRANSFORMS[transform_str] || SUPPORTED_TRANSFORMS[transform_str.downcase] || "" end |
.get_transform_key_value_delimiter ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get transform key-value delimiter
161 162 163 |
# File 'lib/imagekitio/helpers/transformation_utils.rb', line 161 def get_transform_key_value_delimiter TRANSFORM_KEY_VALUE_DELIMITER end |
.safe_btoa(str) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Safe base64 encoding
166 167 168 169 |
# File 'lib/imagekitio/helpers/transformation_utils.rb', line 166 def safe_btoa(str) require("base64") Base64.strict_encode64(str) end |