Product-Images Schema

Schema definition for the Product-Images object in product data

Product-Images Schema

This is a data schema, not an API endpoint. The Product-Images object describes the shape of data returned inside product records by the Product Opener API.

{
  "type": "object",
  "title": "Product-Images",
  "description": "Information about Images of a product.\n\nImages ensure the reliability of Open Food Facts data.\nIt provides a primary source and proof of all the structured data.\nYou may therefore want to display it along the structured information.\n\nSee also tutorials about images:\n* [Getting images](https://openfoodfacts.github.io/openfoodfacts-server/api/how-to-download-images/)\n* [Uploading images](https://openfoodfacts.github.io/openfoodfacts-server/api/tutorial-uploading-photo-to-a-product/)\n",
  "properties": {
    "images": {
      "description": "This contains properties for all images contained on the product.\n",
      "type": "object",
      "title": "product_images_properties",
      "properties": {
        "front": {
          "title": "image_role",
          "type": "object",
          "description": "property of an image (or part thereof) selected for a particular role and a particular language.\n",
          "properties": {
            "angle": {
              "type": "integer",
              "example": 0,
              "description": "The angle of the image rotation (if it was rotated)."
            },
            "coordinates_image_size": {
              "type": "string",
              "example": "full"
            },
            "geometry": {
              "type": "string",
              "example": "0x0--1--1"
            },
            "imgid": {
              "type": "string",
              "example": "121",
              "description": "The id of the original/source image that was selected to edit(rotate, normalize etc) to produce this new image."
            },
            "normalize": {
              "type": [
                "string",
                "boolean",
                "null"
              ],
              "examples": [
                null,
                "false",
                "true"
              ],
              "description": "Normalize colors."
            },
            "rev": {
              "type": "string",
              "example": "420"
            },
            "sizes": {
              "type": "object",
              "description": "The available image sizes for the product (both reduced and full). \nThe reduced images are the ones with numbers as the key( 100, 200 etc)\nwhile the full images have `full` as the key.\n",
              "properties": {
                "100": {
                  "type": "object",
                  "title": "image_size",
                  "description": "Width and height of an image\n",
                  "properties": {
                    "h": {
                      "type": "integer",
                      "example": 400,
                      "description": "The height of the reduced/full image in pixels.\n"
                    },
                    "w": {
                      "type": "integer",
                      "example": 255,
                      "description": "The width of the reduced/full image in pixels.\n"
                    }
                  }
                },
                "200": {
                  "type": "object",
                  "title": "image_size",
                  "description": "Width and height of an image\n",
                  "properties": {
                    "h": {
                      "type": "integer",
                      "example": 400,
                      "description": "The height of the reduced/full image in pixels.\n"
                    },
                    "w": {
                      "type": "integer",
                      "example": 255,
                      "description": "The width of the reduced/full image in pixels.\n"
                    }
                  }
                },
                "400": {
                  "type": "object",
                  "title": "image_size",
                  "description": "Width and height of an image\n",
                  "properties": {
                    "h": {
                      "type": "integer",
                      "example": 400,
                      "description": "The height of the reduced/full image in pixels.\n"
                    },
                    "w": {
                      "type": "integer",
                      "example": 255,
                      "description": "The width of the reduced/full image in pixels.\n"
                    }
                  }
                },
                "full": {
                  "type": "object",
                  "title": "image_size",
                  "description": "Width and height of an image\n",
                  "properties": {
                    "h": {
                      "type": "integer",
                      "example": 400,
                      "description": "The height of the reduced/full image in pixels.\n"
                    },
                    "w": {
                      "type": "integer",
                      "example": 255,
                      "description": "The width of the reduced/full image in pixels.\n"
                    }
                  }
                }
              }
            },
            "white_magic": {
              "type": [
                "string",
                "boolean",
                "null"
              ],
              "examples": [
                null,
                "false",
                "true"
              ],
              "description": "Photo on white background : Try to remove the background.\n"
            },
            "x1": {
              "type": "string",
              "example": "-1"
            },
            "x2": {
              "type": "string",
              "example": "-1"
            },
            "y1": {
              "type": "string",
              "example": "-1"
            },
            "y2": {
              "type": "string",
              "example": "-1"
            }
          }
        }
      },
      "additionalProperties": {
        "type": "object",
        "title": "image",
        "description": "This object represent an image that was uploaded to a product.\n\"imgid\" is an integer which is a sequential number unique to each picture.\n",
        "properties": {
          "imgid": {
            "type": "integer",
            "example": 123456789,
            "description": "If the image is selected as the front / ingredients / nutrition / packaging image,\nthis is the index to access the original image URL in the `images` field of the product.\nIf the image is not selected as one of these, this field is null.\n\nSo if the product has the following `images` field:\n\n```json\n\"images\": {\n  1: { ... },\n  front_en: { imgid: 1, ... },\n  ...\n}\n```\n\nthen the front image can be accessed by `images[1]`.\n"
          },
          "sizes": {
            "type": "object",
            "description": "The available image sizes for the product (both reduced and full).\nThe reduced images are the ones with numbers as the key( 100, 200 etc)\nwhile the full images have `full` as the key.\n",
            "properties": {
              "full": {
                "type": "object",
                "title": "image_size",
                "description": "Width and height of an image\n",
                "properties": {
                  "h": {
                    "type": "integer",
                    "example": 400,
                    "description": "The height of the reduced/full image in pixels.\n"
                  },
                  "w": {
                    "type": "integer",
                    "example": 255,
                    "description": "The width of the reduced/full image in pixels.\n"
                  }
                }
              }
            },
            "patternProperties": {
              "(?<image_size>100|400)": {
                "description": "properties of thumbnail of size `image_size`.\n**TODO** explain how to compute name\n\nFor real type: see description of property `full`.\n(Put this way because of a [bug in rapidoc](https://github.com/rapi-doc/RapiDoc/issues/880))\n",
                "type": "string"
              }
            }
          },
          "uploaded_t": {
            "type": "string",
            "example": "1457680652",
            "description": "The time the image was uploaded (as unix timestamp).\n"
          },
          "uploader": {
            "type": "string",
            "example": "openfoodfacts-contributors",
            "description": "The contributor that uploaded the image.\n"
          }
        }
      },
      "propertyNames": {
        "type": "integer"
      },
      "patternProperties": {
        "(?<imgid>\\d+)": {
          "description": "See property `1` to get the real type of those objects\n(Put this way because of a [bug in rapidoc](https://github.com/rapi-doc/RapiDoc/issues/880))\n",
          "type": "string"
        },
        "(?<image_type>front|nutrition|ingredients|packaging)_(?<language_code>\\w\\w)": {
          "description": "See property `front` to get the real type of those objects\n(Put this way because of a [bug in rapidoc](https://github.com/rapi-doc/RapiDoc/issues/880))\n",
          "type": "string"
        }
      }
    },
    "last_image_dates_tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "last_image_t": {
      "description": "timestamp of last image upload (or update?)",
      "type": "integer"
    },
    "selected_images": {
      "type": "object",
      "title": "product_selected_images",
      "description": "URL for selected (important) images of the product.\n\nThis is very handy if you display the product to users.\n",
      "properties": {
        "front": {
          "type": "object",
          "description": "URLs of thumbnails image of image of type `image_type`",
          "properties": {
            "display": {
              "description": "Thumbnail urls of product image (front) adapted to display on product page\n",
              "type": "object",
              "patternProperties": {
                "(?<language_code>\\w\\w)": {
                  "type": "string",
                  "description": "url of the image for language `language_code`"
                }
              }
            },
            "small": {
              "description": "Thumbnail urls of product image (front) adapted to display on product list page\n",
              "type": "object",
              "patternProperties": {
                "(?<language_code>\\w\\w)": {
                  "type": "string",
                  "description": "url of the image for language `language_code`"
                }
              }
            },
            "thumb": {
              "description": "Thumbnail urls of product image (front) in smallest format\n",
              "type": "object",
              "patternProperties": {
                "(?<language_code>\\w\\w)": {
                  "type": "string",
                  "description": "url of the image for language `language_code`"
                }
              }
            }
          }
        }
      },
      "patternProperties": {
        "(?<image_type>front|packaging|ingredients|nutrition)": {
          "description": "See property `front` to get the real type of those objects\n(Put this way because of a [bug in rapidoc](https://github.com/rapi-doc/RapiDoc/issues/880))\n",
          "type": "string"
        }
      }
    },
    "image_small_url": {
      "type": "string"
    },
    "image_thumb_url": {
      "type": "string"
    },
    "image_url": {
      "type": "string"
    }
  },
  "patternProperties": {
    "image(_(?<image_type>front|packaging|ingredients|nutrition))?(_(?<image_size>small|thumb))?_url": {
      "description": "the URL of image of type `image_type` in size `image_size` (or full size if not given).\n\nThe `image_type` tells which image the url correspond to. `image_type` is `front` if not provided.\n\nThe image is the one for current language (affected by `lc` parameter) if an image exists for this language, the image in main product language otherwise.\n\n**IMPORTANT:** you should use `selected_images` field instead of this one.\n",
      "type": "string"
    }
  }
}