Images

Select and Crop Image

Changed on

Cropping is only relevant for editing existing products. You cannot crop an image the first time you upload it to the system.

post/cgi/product_image_crop.pl

Request

  • Base URL
    https://world.openfoodfacts.net
  • Auth
    API key in header User-Agent

Request body multipart/form-data

codestring required

Barcode of the product.

imgidinteger required

identifier of the image to select, it should be a number

idstring required

identifier of the selected image field, should be in the format {IMAGE_TYPE}_{LANG} format, where IMAGE_TYPE is one of front|ingredients|nutrition|packaging and LANG is the 2 letter language code. Note that if you select an image for the main language of the product (ex: ingredients_it if it is the main language), this image will be displayed on Product Opener for all languages (ex: on https://fr.openfoodfacts.org, unless ingredients_fr exists).

Also note that "other" is not a valid image type, as it makes no sens to crop an image which is not selected.

x1integer

X origin coordinate of the crop, it must be lower than x2

y1integer

Y origin coordinate of the crop, it must be lower than y2

x2integer

X end coordinate of the crop, it must be higher than x1

y2integer

Y end coordinate of the crop, it must be higher than y1

angleinteger

angle of the rotation to apply on the selected image. passing 90 as value rotate the image 90 degrees counter-clockwise.

normalize'true' | 'false'

whether the selected image should be normalized using ImageMagick

white_magic'true' | 'false'

whether the source image should be white magiced (background removal) using ImageMagick.

commentstring

A comment on the contribution. It will be shown in product changes history. Adding meaningful comments help moderators and users understand a single product history.

app_namestring

Name of the app providing the information

app_versionstring

Version of the app providing the information

app_uuidstring

When an app uses a single user to log its contributions, it might be interesting to know which user of the app is providing the information. You can use this field to provide an identifier (eg: an sha1 of the username) that's privacy preserving. Make sure that your salt is strong, perfectly random and secret

In case we have trouble with one of your user, it helps our moderators revert edits.

User-Agentstring

It is required that you pass a specific User-Agent header when you do an API request. But some times it's not possible to modify such a header (eg. request using JavaScript in a browser). In such cases, you can override it with this parameter.

Example request

{
  "code": "04963406",
  "imgid": 2,
  "id": "front_en",
  "x2": 145,
  "y2": 145,
  "normalize": "false"
}

Response

OK

statusstring
imgidinteger

identifier of the processed image

imagefieldstring

identifier of the selected image field (corresponding to the id parameter)

Example response

{
  "status": "status ok",
  "imgid": 2
}

Changes

    • breaking

      added to the request body allOf list

    • breaking

      the response's body type changed from no type to object for status

    • warning

      removed from the request body allOf list

    3 more changes in this revision