# V1 ## List images `images.v1.list(V1ListParams**kwargs) -> SyncV4PagePagination[V1ListResponse]` **get** `/accounts/{account_id}/images/v1` List up to 100 images with one request. Use the optional parameters below to get a specific range of images. ### Parameters - `account_id: str` Account identifier tag. - `creator: Optional[str]` Internal user ID set within the creator field. Setting to empty string "" will return images where creator field is not set - `page: Optional[float]` Page number of paginated results. - `per_page: Optional[float]` Number of items per page. ### Returns - `class V1ListResponse: …` - `images: Optional[List[Image]]` - `id: Optional[str]` Image unique identifier. - `creator: Optional[str]` Can set the creator field with an internal user ID. - `filename: Optional[str]` Image file name. - `meta: Optional[object]` User modifiable key-value store. Can be used for keeping references to another system of record for managing images. Metadata must not exceed 1024 bytes. - `require_signed_urls: Optional[bool]` Indicates whether the image can be a accessed only using it's UID. If set to true, a signed token needs to be generated with a signing key to view the image. - `uploaded: Optional[datetime]` When the media item was uploaded. - `variants: Optional[List[str]]` Object specifying available variants for an image. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.images.v1.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) page = page.result.items[0] print(page.images) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "images": [ { "id": "id", "creator": "107b9558-dd06-4bbd-5fef-9c2c16bb7900", "filename": "logo.png", "meta": { "key": "value" }, "requireSignedURLs": true, "uploaded": "2014-01-02T02:20:00.123Z", "variants": [ "https://imagedelivery.net/MTt4OTd0b0w5aj/107b9558-dd06-4bbd-5fef-9c2c16bb7900/thumbnail", "https://imagedelivery.net/MTt4OTd0b0w5aj/107b9558-dd06-4bbd-5fef-9c2c16bb7900/hero", "https://imagedelivery.net/MTt4OTd0b0w5aj/107b9558-dd06-4bbd-5fef-9c2c16bb7900/original" ] } ] }, "success": true } ``` ## Image details `images.v1.get(strimage_id, V1GetParams**kwargs) -> Image` **get** `/accounts/{account_id}/images/v1/{image_id}` Fetch details for a single image. ### Parameters - `account_id: str` Account identifier tag. - `image_id: str` Image unique identifier. ### Returns - `class Image: …` - `id: Optional[str]` Image unique identifier. - `creator: Optional[str]` Can set the creator field with an internal user ID. - `filename: Optional[str]` Image file name. - `meta: Optional[object]` User modifiable key-value store. Can be used for keeping references to another system of record for managing images. Metadata must not exceed 1024 bytes. - `require_signed_urls: Optional[bool]` Indicates whether the image can be a accessed only using it's UID. If set to true, a signed token needs to be generated with a signing key to view the image. - `uploaded: Optional[datetime]` When the media item was uploaded. - `variants: Optional[List[str]]` Object specifying available variants for an image. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) image = client.images.v1.get( image_id="image_id", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(image.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "id", "creator": "107b9558-dd06-4bbd-5fef-9c2c16bb7900", "filename": "logo.png", "meta": { "key": "value" }, "requireSignedURLs": true, "uploaded": "2014-01-02T02:20:00.123Z", "variants": [ "https://imagedelivery.net/MTt4OTd0b0w5aj/107b9558-dd06-4bbd-5fef-9c2c16bb7900/thumbnail", "https://imagedelivery.net/MTt4OTd0b0w5aj/107b9558-dd06-4bbd-5fef-9c2c16bb7900/hero", "https://imagedelivery.net/MTt4OTd0b0w5aj/107b9558-dd06-4bbd-5fef-9c2c16bb7900/original" ] }, "success": true } ``` ## Upload an image `images.v1.create(V1CreateParams**kwargs) -> Image` **post** `/accounts/{account_id}/images/v1` Upload an image with up to 10 Megabytes using a single HTTP POST (multipart/form-data) request. An image can be uploaded by sending an image file or passing an accessible to an API url. ### Parameters - `account_id: str` Account identifier tag. - `id: Optional[str]` An optional custom unique identifier for your image. - `creator: Optional[str]` Can set the creator field with an internal user ID. - `file: Optional[FileTypes]` An image binary data. Only needed when type is uploading a file. - `metadata: Optional[object]` User modifiable key-value store. Can use used for keeping references to another system of record for managing images. - `require_signed_urls: Optional[bool]` Indicates whether the image requires a signature token for the access. - `url: Optional[str]` A URL to fetch an image from origin. Only needed when type is uploading from a URL. ### Returns - `class Image: …` - `id: Optional[str]` Image unique identifier. - `creator: Optional[str]` Can set the creator field with an internal user ID. - `filename: Optional[str]` Image file name. - `meta: Optional[object]` User modifiable key-value store. Can be used for keeping references to another system of record for managing images. Metadata must not exceed 1024 bytes. - `require_signed_urls: Optional[bool]` Indicates whether the image can be a accessed only using it's UID. If set to true, a signed token needs to be generated with a signing key to view the image. - `uploaded: Optional[datetime]` When the media item was uploaded. - `variants: Optional[List[str]]` Object specifying available variants for an image. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) image = client.images.v1.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(image.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "id", "creator": "107b9558-dd06-4bbd-5fef-9c2c16bb7900", "filename": "logo.png", "meta": { "key": "value" }, "requireSignedURLs": true, "uploaded": "2014-01-02T02:20:00.123Z", "variants": [ "https://imagedelivery.net/MTt4OTd0b0w5aj/107b9558-dd06-4bbd-5fef-9c2c16bb7900/thumbnail", "https://imagedelivery.net/MTt4OTd0b0w5aj/107b9558-dd06-4bbd-5fef-9c2c16bb7900/hero", "https://imagedelivery.net/MTt4OTd0b0w5aj/107b9558-dd06-4bbd-5fef-9c2c16bb7900/original" ] }, "success": true } ``` ## Update image `images.v1.edit(strimage_id, V1EditParams**kwargs) -> Image` **patch** `/accounts/{account_id}/images/v1/{image_id}` Update image access control. On access control change, all copies of the image are purged from cache. ### Parameters - `account_id: str` Account identifier tag. - `image_id: str` Image unique identifier. - `creator: Optional[str]` Can set the creator field with an internal user ID. - `metadata: Optional[object]` User modifiable key-value store. Can be used for keeping references to another system of record for managing images. No change if not specified. - `require_signed_urls: Optional[bool]` Indicates whether the image can be accessed using only its UID. If set to `true`, a signed token needs to be generated with a signing key to view the image. Returns a new UID on a change. No change if not specified. ### Returns - `class Image: …` - `id: Optional[str]` Image unique identifier. - `creator: Optional[str]` Can set the creator field with an internal user ID. - `filename: Optional[str]` Image file name. - `meta: Optional[object]` User modifiable key-value store. Can be used for keeping references to another system of record for managing images. Metadata must not exceed 1024 bytes. - `require_signed_urls: Optional[bool]` Indicates whether the image can be a accessed only using it's UID. If set to true, a signed token needs to be generated with a signing key to view the image. - `uploaded: Optional[datetime]` When the media item was uploaded. - `variants: Optional[List[str]]` Object specifying available variants for an image. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) image = client.images.v1.edit( image_id="image_id", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(image.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "id", "creator": "107b9558-dd06-4bbd-5fef-9c2c16bb7900", "filename": "logo.png", "meta": { "key": "value" }, "requireSignedURLs": true, "uploaded": "2014-01-02T02:20:00.123Z", "variants": [ "https://imagedelivery.net/MTt4OTd0b0w5aj/107b9558-dd06-4bbd-5fef-9c2c16bb7900/thumbnail", "https://imagedelivery.net/MTt4OTd0b0w5aj/107b9558-dd06-4bbd-5fef-9c2c16bb7900/hero", "https://imagedelivery.net/MTt4OTd0b0w5aj/107b9558-dd06-4bbd-5fef-9c2c16bb7900/original" ] }, "success": true } ``` ## Delete image `images.v1.delete(strimage_id, V1DeleteParams**kwargs) -> V1DeleteResponse` **delete** `/accounts/{account_id}/images/v1/{image_id}` Delete an image on Cloudflare Images. On success, all copies of the image are deleted and purged from cache. ### Parameters - `account_id: str` Account identifier tag. - `image_id: str` Image unique identifier. ### Returns - `Union[str, object]` - `str` - `object` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) v1 = client.images.v1.delete( image_id="image_id", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(v1) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": {}, "success": true } ``` ## Domain Types ### Image - `class Image: …` - `id: Optional[str]` Image unique identifier. - `creator: Optional[str]` Can set the creator field with an internal user ID. - `filename: Optional[str]` Image file name. - `meta: Optional[object]` User modifiable key-value store. Can be used for keeping references to another system of record for managing images. Metadata must not exceed 1024 bytes. - `require_signed_urls: Optional[bool]` Indicates whether the image can be a accessed only using it's UID. If set to true, a signed token needs to be generated with a signing key to view the image. - `uploaded: Optional[datetime]` When the media item was uploaded. - `variants: Optional[List[str]]` Object specifying available variants for an image. ### V1 List Response - `class V1ListResponse: …` - `images: Optional[List[Image]]` - `id: Optional[str]` Image unique identifier. - `creator: Optional[str]` Can set the creator field with an internal user ID. - `filename: Optional[str]` Image file name. - `meta: Optional[object]` User modifiable key-value store. Can be used for keeping references to another system of record for managing images. Metadata must not exceed 1024 bytes. - `require_signed_urls: Optional[bool]` Indicates whether the image can be a accessed only using it's UID. If set to true, a signed token needs to be generated with a signing key to view the image. - `uploaded: Optional[datetime]` When the media item was uploaded. - `variants: Optional[List[str]]` Object specifying available variants for an image. ### V1 Delete Response - `Union[str, object]` - `str` - `object` # Keys ## List Signing Keys `images.v1.keys.list(KeyListParams**kwargs) -> KeyListResponse` **get** `/accounts/{account_id}/images/v1/keys` Lists your signing keys. These can be found on your Cloudflare Images dashboard. ### Parameters - `account_id: str` Account identifier tag. ### Returns - `class KeyListResponse: …` - `keys: Optional[List[Key]]` - `name: Optional[str]` Key name. - `value: Optional[str]` Key value. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) keys = client.images.v1.keys.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(keys.keys) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "keys": [ { "name": "default", "value": "Oix0bbNaT8Rge9PuyxUBrjI6zrgnsyJ5=" } ] }, "success": true } ``` ## Create a new Signing Key `images.v1.keys.update(strsigning_key_name, KeyUpdateParams**kwargs) -> KeyUpdateResponse` **put** `/accounts/{account_id}/images/v1/keys/{signing_key_name}` Create a new signing key with specified name. Returns all keys available. ### Parameters - `account_id: str` Account identifier tag. - `signing_key_name: str` ### Returns - `class KeyUpdateResponse: …` - `keys: Optional[List[Key]]` - `name: Optional[str]` Key name. - `value: Optional[str]` Key value. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) key = client.images.v1.keys.update( signing_key_name="someKey", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(key.keys) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "keys": [ { "name": "default", "value": "Oix0bbNaT8Rge9PuyxUBrjI6zrgnsyJ5=" } ] }, "success": true } ``` ## Delete Signing Key `images.v1.keys.delete(strsigning_key_name, KeyDeleteParams**kwargs) -> KeyDeleteResponse` **delete** `/accounts/{account_id}/images/v1/keys/{signing_key_name}` Delete signing key with specified name. Returns all keys available. When last key is removed, a new default signing key will be generated. ### Parameters - `account_id: str` Account identifier tag. - `signing_key_name: str` ### Returns - `class KeyDeleteResponse: …` - `keys: Optional[List[Key]]` - `name: Optional[str]` Key name. - `value: Optional[str]` Key value. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) key = client.images.v1.keys.delete( signing_key_name="someKey", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(key.keys) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "keys": [ { "name": "default", "value": "Oix0bbNaT8Rge9PuyxUBrjI6zrgnsyJ5=" } ] }, "success": true } ``` ## Domain Types ### Key - `class Key: …` - `name: Optional[str]` Key name. - `value: Optional[str]` Key value. ### Key List Response - `class KeyListResponse: …` - `keys: Optional[List[Key]]` - `name: Optional[str]` Key name. - `value: Optional[str]` Key value. ### Key Update Response - `class KeyUpdateResponse: …` - `keys: Optional[List[Key]]` - `name: Optional[str]` Key name. - `value: Optional[str]` Key value. ### Key Delete Response - `class KeyDeleteResponse: …` - `keys: Optional[List[Key]]` - `name: Optional[str]` Key name. - `value: Optional[str]` Key value. # Stats ## Images usage statistics `images.v1.stats.get(StatGetParams**kwargs) -> Stat` **get** `/accounts/{account_id}/images/v1/stats` Fetch image statistics details for Cloudflare Images. The returned statistics detail storage usage, including the current image count vs this account's allowance. ### Parameters - `account_id: str` Account identifier tag. ### Returns - `class Stat: …` - `count: Optional[Count]` - `allowed: Optional[float]` Cloudflare Images allowed usage. - `current: Optional[float]` Cloudflare Images current usage. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) stat = client.images.v1.stats.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(stat.count) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "count": { "allowed": 100000, "current": 1000 } }, "success": true } ``` ## Domain Types ### Stat - `class Stat: …` - `count: Optional[Count]` - `allowed: Optional[float]` Cloudflare Images allowed usage. - `current: Optional[float]` Cloudflare Images current usage. # Variants ## List variants `images.v1.variants.list(VariantListParams**kwargs) -> Variant` **get** `/accounts/{account_id}/images/v1/variants` Lists existing variants. ### Parameters - `account_id: str` Account identifier tag. ### Returns - `class Variant: …` - `variants: Optional[Variants]` - `hero: Optional[VariantsHero]` - `id: str` - `options: VariantsHeroOptions` Allows you to define image resizing sizes for different use cases. - `fit: Literal["scale-down", "contain", "cover", 2 more]` The fit property describes how the width and height dimensions should be interpreted. - `"scale-down"` - `"contain"` - `"cover"` - `"crop"` - `"pad"` - `height: float` Maximum height in image pixels. - `metadata: Literal["keep", "copyright", "none"]` What EXIF data should be preserved in the output image. - `"keep"` - `"copyright"` - `"none"` - `width: float` Maximum width in image pixels. - `never_require_signed_urls: Optional[bool]` Indicates whether the variant can access an image without a signature, regardless of image access control. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) variant = client.images.v1.variants.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(variant.variants) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "variants": { "hero": { "id": "hero", "options": { "fit": "scale-down", "height": 768, "metadata": "none", "width": 1366 }, "neverRequireSignedURLs": true } } }, "success": true } ``` ## Variant details `images.v1.variants.get(strvariant_id, VariantGetParams**kwargs) -> VariantGetResponse` **get** `/accounts/{account_id}/images/v1/variants/{variant_id}` Fetch details for a single variant. ### Parameters - `account_id: str` Account identifier tag. - `variant_id: str` ### Returns - `class VariantGetResponse: …` - `variant: Optional[Variant]` - `id: str` - `options: VariantOptions` Allows you to define image resizing sizes for different use cases. - `fit: Literal["scale-down", "contain", "cover", 2 more]` The fit property describes how the width and height dimensions should be interpreted. - `"scale-down"` - `"contain"` - `"cover"` - `"crop"` - `"pad"` - `height: float` Maximum height in image pixels. - `metadata: Literal["keep", "copyright", "none"]` What EXIF data should be preserved in the output image. - `"keep"` - `"copyright"` - `"none"` - `width: float` Maximum width in image pixels. - `never_require_signed_urls: Optional[bool]` Indicates whether the variant can access an image without a signature, regardless of image access control. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) variant = client.images.v1.variants.get( variant_id="hero", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(variant.variant) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "variant": { "id": "hero", "options": { "fit": "scale-down", "height": 768, "metadata": "none", "width": 1366 }, "neverRequireSignedURLs": true } }, "success": true } ``` ## Create a variant `images.v1.variants.create(VariantCreateParams**kwargs) -> VariantCreateResponse` **post** `/accounts/{account_id}/images/v1/variants` Specify variants that allow you to resize images for different use cases. ### Parameters - `account_id: str` Account identifier tag. - `id: str` - `options: Options` Allows you to define image resizing sizes for different use cases. - `fit: Literal["scale-down", "contain", "cover", 2 more]` The fit property describes how the width and height dimensions should be interpreted. - `"scale-down"` - `"contain"` - `"cover"` - `"crop"` - `"pad"` - `height: float` Maximum height in image pixels. - `metadata: Literal["keep", "copyright", "none"]` What EXIF data should be preserved in the output image. - `"keep"` - `"copyright"` - `"none"` - `width: float` Maximum width in image pixels. - `never_require_signed_urls: Optional[bool]` Indicates whether the variant can access an image without a signature, regardless of image access control. ### Returns - `class VariantCreateResponse: …` - `variant: Optional[Variant]` - `id: str` - `options: VariantOptions` Allows you to define image resizing sizes for different use cases. - `fit: Literal["scale-down", "contain", "cover", 2 more]` The fit property describes how the width and height dimensions should be interpreted. - `"scale-down"` - `"contain"` - `"cover"` - `"crop"` - `"pad"` - `height: float` Maximum height in image pixels. - `metadata: Literal["keep", "copyright", "none"]` What EXIF data should be preserved in the output image. - `"keep"` - `"copyright"` - `"none"` - `width: float` Maximum width in image pixels. - `never_require_signed_urls: Optional[bool]` Indicates whether the variant can access an image without a signature, regardless of image access control. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) variant = client.images.v1.variants.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", id="hero", options={ "fit": "scale-down", "height": 768, "metadata": "none", "width": 1366, }, ) print(variant.variant) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "variant": { "id": "hero", "options": { "fit": "scale-down", "height": 768, "metadata": "none", "width": 1366 }, "neverRequireSignedURLs": true } }, "success": true } ``` ## Update a variant `images.v1.variants.edit(strvariant_id, VariantEditParams**kwargs) -> VariantEditResponse` **patch** `/accounts/{account_id}/images/v1/variants/{variant_id}` Updating a variant purges the cache for all images associated with the variant. ### Parameters - `account_id: str` Account identifier tag. - `variant_id: str` - `options: Options` Allows you to define image resizing sizes for different use cases. - `fit: Literal["scale-down", "contain", "cover", 2 more]` The fit property describes how the width and height dimensions should be interpreted. - `"scale-down"` - `"contain"` - `"cover"` - `"crop"` - `"pad"` - `height: float` Maximum height in image pixels. - `metadata: Literal["keep", "copyright", "none"]` What EXIF data should be preserved in the output image. - `"keep"` - `"copyright"` - `"none"` - `width: float` Maximum width in image pixels. - `never_require_signed_urls: Optional[bool]` Indicates whether the variant can access an image without a signature, regardless of image access control. ### Returns - `class VariantEditResponse: …` - `variant: Optional[Variant]` - `id: str` - `options: VariantOptions` Allows you to define image resizing sizes for different use cases. - `fit: Literal["scale-down", "contain", "cover", 2 more]` The fit property describes how the width and height dimensions should be interpreted. - `"scale-down"` - `"contain"` - `"cover"` - `"crop"` - `"pad"` - `height: float` Maximum height in image pixels. - `metadata: Literal["keep", "copyright", "none"]` What EXIF data should be preserved in the output image. - `"keep"` - `"copyright"` - `"none"` - `width: float` Maximum width in image pixels. - `never_require_signed_urls: Optional[bool]` Indicates whether the variant can access an image without a signature, regardless of image access control. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.images.v1.variants.edit( variant_id="hero", account_id="023e105f4ecef8ad9ca31a8372d0c353", options={ "fit": "scale-down", "height": 768, "metadata": "none", "width": 1366, }, ) print(response.variant) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "variant": { "id": "hero", "options": { "fit": "scale-down", "height": 768, "metadata": "none", "width": 1366 }, "neverRequireSignedURLs": true } }, "success": true } ``` ## Delete a variant `images.v1.variants.delete(strvariant_id, VariantDeleteParams**kwargs) -> VariantDeleteResponse` **delete** `/accounts/{account_id}/images/v1/variants/{variant_id}` Deleting a variant purges the cache for all images associated with the variant. ### Parameters - `account_id: str` Account identifier tag. - `variant_id: str` ### Returns - `Union[str, object]` - `str` - `object` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) variant = client.images.v1.variants.delete( variant_id="hero", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(variant) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": {}, "success": true } ``` ## Domain Types ### Variant - `class Variant: …` - `variants: Optional[Variants]` - `hero: Optional[VariantsHero]` - `id: str` - `options: VariantsHeroOptions` Allows you to define image resizing sizes for different use cases. - `fit: Literal["scale-down", "contain", "cover", 2 more]` The fit property describes how the width and height dimensions should be interpreted. - `"scale-down"` - `"contain"` - `"cover"` - `"crop"` - `"pad"` - `height: float` Maximum height in image pixels. - `metadata: Literal["keep", "copyright", "none"]` What EXIF data should be preserved in the output image. - `"keep"` - `"copyright"` - `"none"` - `width: float` Maximum width in image pixels. - `never_require_signed_urls: Optional[bool]` Indicates whether the variant can access an image without a signature, regardless of image access control. ### Variant Get Response - `class VariantGetResponse: …` - `variant: Optional[Variant]` - `id: str` - `options: VariantOptions` Allows you to define image resizing sizes for different use cases. - `fit: Literal["scale-down", "contain", "cover", 2 more]` The fit property describes how the width and height dimensions should be interpreted. - `"scale-down"` - `"contain"` - `"cover"` - `"crop"` - `"pad"` - `height: float` Maximum height in image pixels. - `metadata: Literal["keep", "copyright", "none"]` What EXIF data should be preserved in the output image. - `"keep"` - `"copyright"` - `"none"` - `width: float` Maximum width in image pixels. - `never_require_signed_urls: Optional[bool]` Indicates whether the variant can access an image without a signature, regardless of image access control. ### Variant Create Response - `class VariantCreateResponse: …` - `variant: Optional[Variant]` - `id: str` - `options: VariantOptions` Allows you to define image resizing sizes for different use cases. - `fit: Literal["scale-down", "contain", "cover", 2 more]` The fit property describes how the width and height dimensions should be interpreted. - `"scale-down"` - `"contain"` - `"cover"` - `"crop"` - `"pad"` - `height: float` Maximum height in image pixels. - `metadata: Literal["keep", "copyright", "none"]` What EXIF data should be preserved in the output image. - `"keep"` - `"copyright"` - `"none"` - `width: float` Maximum width in image pixels. - `never_require_signed_urls: Optional[bool]` Indicates whether the variant can access an image without a signature, regardless of image access control. ### Variant Edit Response - `class VariantEditResponse: …` - `variant: Optional[Variant]` - `id: str` - `options: VariantOptions` Allows you to define image resizing sizes for different use cases. - `fit: Literal["scale-down", "contain", "cover", 2 more]` The fit property describes how the width and height dimensions should be interpreted. - `"scale-down"` - `"contain"` - `"cover"` - `"crop"` - `"pad"` - `height: float` Maximum height in image pixels. - `metadata: Literal["keep", "copyright", "none"]` What EXIF data should be preserved in the output image. - `"keep"` - `"copyright"` - `"none"` - `width: float` Maximum width in image pixels. - `never_require_signed_urls: Optional[bool]` Indicates whether the variant can access an image without a signature, regardless of image access control. ### Variant Delete Response - `Union[str, object]` - `str` - `object` # Blobs ## Base image `images.v1.blobs.get(strimage_id, BlobGetParams**kwargs) -> BinaryResponseContent` **get** `/accounts/{account_id}/images/v1/{image_id}/blob` Fetch base image. For most images this will be the originally uploaded file. For larger images it can be a near-lossless version of the original. ### Parameters - `account_id: str` Account identifier tag. - `image_id: str` Image unique identifier. ### Returns - `BinaryResponseContent` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) blob = client.images.v1.blobs.get( image_id="image_id", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(blob) content = blob.read() print(content) ```