Policy image
akamai_imaging_policy_image
Specify details for an image policy, like transformations to apply and variations in image size and formats. Then reference this data source in the corresponding resource.
See Transform images for a complete list of available transformations for an image policy. To define variables in your policy, see Use variables.
data "akamai_imaging_policy_image" "my-image-policy-definition" {
policy {
breakpoints {
widths = [280, 1080]
}
hosts = ["www.example-1.com", "www.example-2.com"]
output {
adaptive_quality = 50
perceptual_quality = "mediumHigh"
}
transformations {
region_of_interest_crop {
gravity = "Center"
height = 8
region_of_interest {
rectangle_shape {
anchor {
x = 4
y = 5
}
height = 9
width = 8
}
}
style = "fill"
width = 7
}
}
transformations {
append {
gravity = "Center"
gravity_priority = "horizontal"
image {
text_image {
fill = "#000000"
size = 72
stroke = "#FFFFFF"
stroke_size = 0
text = "test"
}
}
preserve_minor_dimension = true
}
}
transformations {
trim {
fuzz = 0.08
padding = 0
}
}
transformations {
if_dimension {
default {
resize {
aspect = "fit"
height_var = "ResizeDim"
type = "normal"
width_var = "ResizeDim"
}
}
dimension = "height"
less_than {
crop {
allow_expansion = true
gravity = "Center"
height_var = "ResizeDim"
width_var = "ResizeDim"
x_position = 0
y_position = 0
}
}
value_var = "MinDim"
}
}
transformations {
im_query {
allowed_transformations = ["Append", "Blur", "Crop"]
query_var = "imq"
}
}
variables {
default_value = "280"
name = "ResizeDim"
type = "number"
}
variables {
default_value = "1000"
name = "MinDim"
type = "number"
}
variables {
default_value = ""
name = "imq"
type = "string"
}
}
}
output "my-image-policy" {
value = data.akamai_imaging_policy_image.my-image-policy-definition
}
resource "akamai_imaging_policy_image" "my-image-policy" {
activate_on_production = false
contract_id = "12345"
policy_id = "my-image-policy-1"
policyset_id = akamai_imaging_policy_set.my-policy-set.id
json = data.akamai_imaging_policy_image.my-image-policy-definition.json
}
Changes to Outputs:
+ my-image-policy = {
+ id = "12abcd34ef5ghi6i78klmn9012op34qrstuv56wx7yz"
+ json = jsonencode(
{
+ breakpoints = {
+ widths = [
+ 280,
+ 1080,
]
}
+ hosts = [
+ "www.example-1.com",
+ "www.example-2.com",
]
+ output = {
+ adaptiveQuality = 50
+ perceptualQuality = "mediumHigh"
}
+ transformations = [
+ {
+ gravity = "Center"
+ height = 8
+ regionOfInterest = {
+ anchor = {
+ x = 4
+ y = 5
}
+ height = 9
+ width = 8
}
+ style = "fill"
+ transformation = "RegionOfInterestCrop"
+ width = 7
},
+ {
+ gravity = "Center"
+ gravityPriority = "horizontal"
+ image = {
+ fill = "#000000"
+ size = 72
+ stroke = "#FFFFFF"
+ strokeSize = 0
+ text = "test"
+ type = "Text"
}
+ preserveMinorDimension = true
+ transformation = "Append"
},
+ {
+ fuzz = 0.08
+ padding = 0
+ transformation = "Trim"
},
+ {
+ default = {
+ aspect = "fit"
+ height = {
+ var = "ResizeDim"
}
+ transformation = "Resize"
+ type = "normal"
+ width = {
+ var = "ResizeDim"
}
}
+ dimension = "height"
+ lessThan = {
+ allowExpansion = true
+ gravity = "Center"
+ height = {
+ var = "ResizeDim"
}
+ transformation = "Crop"
+ width = {
+ var = "ResizeDim"
}
+ xPosition = 0
+ yPosition = 0
}
+ transformation = "IfDimension"
+ value = {
+ var = "MinDim"
}
},
+ {
+ allowedTransformations = [
+ "Append",
+ "Blur",
+ "Crop",
]
+ query = {
+ var = "imq"
}
+ transformation = "ImQuery"
},
]
+ variables = [
+ {
+ defaultValue = "280"
+ name = "ResizeDim"
+ type = "number"
},
+ {
+ defaultValue = "1000"
+ name = "MinDim"
+ type = "number"
},
+ {
+ defaultValue = ""
+ name = "imq"
+ type = "string"
},
]
}
)
+ policy = [
+ {
+ breakpoints = [
+ {
+ widths = [
+ 280,
+ 1080,
]
},
]
+ hosts = [
+ "www.example-1.com",
+ "www.example-2.com",
]
+ output = [
+ {
+ adaptive_quality = "50"
+ allow_pristine_on_downsize = ""
+ allowed_formats = []
+ forced_formats = []
+ perceptual_quality = "mediumHigh"
+ perceptual_quality_floor = ""
+ perceptual_quality_var = ""
+ prefer_modern_formats = ""
+ quality = ""
+ quality_var = ""
},
]
+ post_breakpoint_transformations = []
+ rollout_duration = ""
+ serve_stale_duration = ""
+ transformations = [
+ {
+ append = []
+ aspect_crop = []
+ background_color = []
+ blur = []
+ chroma_key = []
+ composite = []
+ compound = []
+ contrast = []
+ crop = []
+ face_crop = []
+ feature_crop = []
+ fit_and_fill = []
+ goop = []
+ grayscale = []
+ hsl = []
+ hsv = []
+ if_dimension = []
+ if_orientation = []
+ im_query = []
+ max_colors = []
+ mirror = []
+ mono_hue = []
+ opacity = []
+ region_of_interest_crop = [
+ {
+ gravity = "Center"
+ gravity_var = ""
+ height = "8"
+ height_var = ""
+ region_of_interest = [
+ {
+ circle_shape = []
+ point_shape = []
+ polygon_shape = []
+ rectangle_shape = [
+ {
+ anchor = [
+ {
+ x = "4"
+ x_var = ""
+ y = "5"
+ y_var = ""
},
]
+ height = "9"
+ height_var = ""
+ width = "8"
+ width_var = ""
},
]
+ union_shape = []
},
]
+ style = "fill"
+ style_var = ""
+ width = "7"
+ width_var = ""
},
]
+ relative_crop = []
+ remove_color = []
+ resize = []
+ rotate = []
+ scale = []
+ shear = []
+ smart_crop = []
+ trim = []
+ unsharp_mask = []
},
+ {
+ append = [
+ {
+ gravity = "Center"
+ gravity_priority = "horizontal"
+ gravity_priority_var = ""
+ gravity_var = ""
+ image = [
+ {
+ box_image = []
+ circle_image = []
+ text_image = [
+ {
+ fill = "#000000"
+ fill_var = ""
+ size = "72"
+ size_var = ""
+ stroke = "#FFFFFF"
+ stroke_size = "0"
+ stroke_size_var = ""
+ stroke_var = ""
+ text = "test"
+ text_var = ""
+ transformation = []
+ typeface = ""
+ typeface_var = ""
},
]
+ url_image = []
},
]
+ preserve_minor_dimension = "true"
+ preserve_minor_dimension_var = ""
},
]
+ aspect_crop = []
+ background_color = []
+ blur = []
+ chroma_key = []
+ composite = []
+ compound = []
+ contrast = []
+ crop = []
+ face_crop = []
+ feature_crop = []
+ fit_and_fill = []
+ goop = []
+ grayscale = []
+ hsl = []
+ hsv = []
+ if_dimension = []
+ if_orientation = []
+ im_query = []
+ max_colors = []
+ mirror = []
+ mono_hue = []
+ opacity = []
+ region_of_interest_crop = []
+ relative_crop = []
+ remove_color = []
+ resize = []
+ rotate = []
+ scale = []
+ shear = []
+ smart_crop = []
+ trim = []
+ unsharp_mask = []
},
+ {
+ append = []
+ aspect_crop = []
+ background_color = []
+ blur = []
+ chroma_key = []
+ composite = []
+ compound = []
+ contrast = []
+ crop = []
+ face_crop = []
+ feature_crop = []
+ fit_and_fill = []
+ goop = []
+ grayscale = []
+ hsl = []
+ hsv = []
+ if_dimension = []
+ if_orientation = []
+ im_query = []
+ max_colors = []
+ mirror = []
+ mono_hue = []
+ opacity = []
+ region_of_interest_crop = []
+ relative_crop = []
+ remove_color = []
+ resize = []
+ rotate = []
+ scale = []
+ shear = []
+ smart_crop = []
+ trim = [
+ {
+ fuzz = "0.08"
+ fuzz_var = ""
+ padding = "0"
+ padding_var = ""
},
]
+ unsharp_mask = []
},
+ {
+ append = []
+ aspect_crop = []
+ background_color = []
+ blur = []
+ chroma_key = []
+ composite = []
+ compound = []
+ contrast = []
+ crop = []
+ face_crop = []
+ feature_crop = []
+ fit_and_fill = []
+ goop = []
+ grayscale = []
+ hsl = []
+ hsv = []
+ if_dimension = [
+ {
+ default = [
+ {
+ append = []
+ aspect_crop = []
+ background_color = []
+ blur = []
+ chroma_key = []
+ composite = []
+ compound = []
+ contrast = []
+ crop = []
+ face_crop = []
+ feature_crop = []
+ fit_and_fill = []
+ goop = []
+ grayscale = []
+ hsl = []
+ hsv = []
+ if_dimension = []
+ if_orientation = []
+ im_query = []
+ max_colors = []
+ mirror = []
+ mono_hue = []
+ opacity = []
+ region_of_interest_crop = []
+ relative_crop = []
+ remove_color = []
+ resize = [
+ {
+ aspect = "fit"
+ aspect_var = ""
+ height = ""
+ height_var = "ResizeDim"
+ type = "normal"
+ type_var = ""
+ width = ""
+ width_var = "ResizeDim"
},
]
+ rotate = []
+ scale = []
+ shear = []
+ smart_crop = []
+ trim = []
+ unsharp_mask = []
},
]
+ dimension = "height"
+ dimension_var = ""
+ equal = []
+ greater_than = []
+ less_than = [
+ {
+ append = []
+ aspect_crop = []
+ background_color = []
+ blur = []
+ chroma_key = []
+ composite = []
+ compound = []
+ contrast = []
+ crop = [
+ {
+ allow_expansion = "true"
+ allow_expansion_var = ""
+ gravity = "Center"
+ gravity_var = ""
+ height = ""
+ height_var = "ResizeDim"
+ width = ""
+ width_var = "ResizeDim"
+ x_position = "0"
+ x_position_var = ""
+ y_position = "0"
+ y_position_var = ""
},
]
+ face_crop = []
+ feature_crop = []
+ fit_and_fill = []
+ goop = []
+ grayscale = []
+ hsl = []
+ hsv = []
+ if_dimension = []
+ if_orientation = []
+ im_query = []
+ max_colors = []
+ mirror = []
+ mono_hue = []
+ opacity = []
+ region_of_interest_crop = []
+ relative_crop = []
+ remove_color = []
+ resize = []
+ rotate = []
+ scale = []
+ shear = []
+ smart_crop = []
+ trim = []
+ unsharp_mask = []
},
]
+ value = ""
+ value_var = "MinDim"
},
]
+ if_orientation = []
+ im_query = []
+ max_colors = []
+ mirror = []
+ mono_hue = []
+ opacity = []
+ region_of_interest_crop = []
+ relative_crop = []
+ remove_color = []
+ resize = []
+ rotate = []
+ scale = []
+ shear = []
+ smart_crop = []
+ trim = []
+ unsharp_mask = []
},
+ {
+ append = []
+ aspect_crop = []
+ background_color = []
+ blur = []
+ chroma_key = []
+ composite = []
+ compound = []
+ contrast = []
+ crop = []
+ face_crop = []
+ feature_crop = []
+ fit_and_fill = []
+ goop = []
+ grayscale = []
+ hsl = []
+ hsv = []
+ if_dimension = []
+ if_orientation = []
+ im_query = [
+ {
+ allowed_transformations = [
+ "Append",
+ "Blur",
+ "Crop",
]
+ query_var = "imq"
},
]
+ max_colors = []
+ mirror = []
+ mono_hue = []
+ opacity = []
+ region_of_interest_crop = []
+ relative_crop = []
+ remove_color = []
+ resize = []
+ rotate = []
+ scale = []
+ shear = []
+ smart_crop = []
+ trim = []
+ unsharp_mask = []
},
]
+ variables = [
+ {
+ default_value = "280"
+ enum_options = []
+ name = "ResizeDim"
+ postfix = ""
+ prefix = ""
+ type = "number"
},
+ {
+ default_value = "1000"
+ enum_options = []
+ name = "MinDim"
+ postfix = ""
+ prefix = ""
+ type = "number"
},
+ {
+ default_value = ""
+ enum_options = []
+ name = "imq"
+ postfix = ""
+ prefix = ""
+ type = "string"
},
]
},
]
}
Arguments
Pass the required policy
argument in the body of the declaration to specify settings in it for an image policy.
Argument | Required | Description |
---|---|---|
breakpoints |
The list of breakpoint widths in pixels used to create derivative images. |
|
hosts |
The hosts allowed for image URLs within transformations or variables. | |
output |
The output quality and formats that are created for each resized image. If unspecified, image formats are created to support all browsers at the default quality level (85 ) including formats, like WEBP, JPEG2000, and JPEG-XR for specific browsers. Includes:
|
|
post_breakpoint_transformations |
The set of post-processing transformations applied to the image after image and quality settings have been applied. This is a subset of the complete list of transformations and includes:
|
|
rollout_duration |
The amount of time in seconds that it takes for the policy to roll out. During the rollout, the proportion of images with the new policy applied continually increases until cached videos associated with the previous version of the policy are no longer being served. The default is 3600 seconds. |
|
transformations |
The set of image transformations applied to the original image. If unspecified, no operations are performed. For information about available transformations and their supporting arguments, see Transform images. | |
serve_stale_duration |
The amount of time in seconds that the policy serves stale images. If possible, during the serve stale period, real-time images attempt to use the offline image from the previous policy version. | |
variables |
The variables available for the policy. You can reference any variable declared here in transformations and output . You can also dynamically pass in these variable names and values as query parameters in the image's request URL. See Use variables for more information. Includes:
|
Attributes
Returned to you is the JSON-encoded image policy.
Updated about 15 hours ago