---
title: "Select and Crop Image"
method: POST
path: "/cgi/product_image_crop.pl"
tags: ["Images"]
---

# Select and Crop Image

`POST /cgi/product_image_crop.pl`

## Request

- Base URL: `https://world.openfoodfacts.net`
- URL: `https://world.openfoodfacts.net/cgi/product_image_crop.pl`
- Auth: API key in header `User-Agent`

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

## Request body `multipart/form-data`

- object: Properties that goes in change ref
  - `code` string, required: Barcode of the product.
  - `imgid` integer, required: identifier of the image to select, it should be a number
  - `id` string, 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.
  - `x1` integer: X origin coordinate of the crop, it must be lower than x2
  - `y1` integer: Y origin coordinate of the crop, it must be lower than y2
  - `x2` integer: X end coordinate of the crop, it must be higher than x1
  - `y2` integer: Y end coordinate of the crop, it must be higher than y1
  - `angle` integer: 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.
  - `comment` string: 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_name` string: Name of the app providing the information
  - `app_version` string: Version of the app providing the information
  - `app_uuid` string: 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-Agent` string: 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.

## Response `200`

OK

- ProductImageCrop
  - `status` string
  - `imgid` integer: identifier of the processed image
  - `imagefield` string: identifier of the selected image field (corresponding to the `id` parameter)

## Changes

- **2026-11-18** `ebaef6823f1f`: 2 breaking, 1 warning, 3 info
  - added `#/components/schemas/crop_a_photo, #/components/schemas/change_ref_properties` to the request body `allOf` list
  - the response's body type changed from no type to `object` for status `200`
  - removed `#/components/schemas/crop_a_photo.yaml, #/components/schemas/change_ref_properties.yaml` from the request body `allOf` list
  - added the optional property `imagefield` to the response with the `200` status
  - …2 more
- **2025-08-12** `8d63bb2912e0`: 1 breaking
  - the response's body type changed from `object` to no type for status `200`
- **2025-07-02** `7193ad484e5d`: 2 info
  - api tag `Images` added
  - api tag `Write Requests` removed
- **2025-05-26** `62cdffa6beab`: 1 breaking
  - added `#/components/schemas/crop_a_photo.yaml, #/components/schemas/change_ref_properties.yaml` to the request body `allOf` list

[Operation history](https://skmtc.dev/openfoodfacts/apis/open-food-facts-open-api/changes/cgi/product_image_crop.pl/post.md)

---

[API](https://skmtc.dev/openfoodfacts/apis/open-food-facts-open-api.md) - [All operations](https://skmtc.dev/openfoodfacts/apis/open-food-facts-open-api/llms.txt) - [OpenAPI document](https://skmtc.dev/openfoodfacts/apis/open-food-facts-open-api/revisions/ebaef6823f1f?raw)
