Changes

Jump to navigation Jump to search
1,034 bytes added ,  13:36, 8 December 2022
no edit summary
Line 1: Line 1:  
[[Category:Developer]] [[Category:API]]
 
[[Category:Developer]] [[Category:API]]
 
<Back to [[API/Write]](Required reading)
 
<Back to [[API/Write]](Required reading)
 
+
<big>
 +
The new version of the documentation is available here:
 +
* [https://openfoodfacts.github.io/api-documentation/ API V2 - Comprehensive but not OpenAPI compliant] - It contains uses cases for displaying a product, and letting your users add the data required to get the Nutri-Score, the NOVA classification, additives, and the Eco-Score.
 +
* [https://openfoodfacts.github.io/openfoodfacts-server/reference/api/ API V2 - new OpenAPI documentation] - Work in Progress
 +
* [https://openfoodfacts.github.io/openfoodfacts-server/reference/api-v3/ API V3 - new OpenAPI documentation] - Work in Progress
 +
</big>
 
=== Manipulating photos for a product ===
 
=== Manipulating photos for a product ===
 
==== Understanding products and photos ====
 
==== Understanding products and photos ====
 
* Photos are the primary source of Open Food Facts.
 
* Photos are the primary source of Open Food Facts.
 
* We need good photos of the '''product''', of its '''ingredients''' and '''nutrition table'''. (and for each language present on the packaging)
 
* We need good photos of the '''product''', of its '''ingredients''' and '''nutrition table'''. (and for each language present on the packaging)
 +
* <span style="color:#d33">Good photos means a minimal allowed size: 640 x 160.</span>
 
* Please encourage your users to add as many photos as possible, even if the product is already complete (in that case, don't set them as default photos for  front, ingredients, and nutrition)
 
* Please encourage your users to add as many photos as possible, even if the product is already complete (in that case, don't set them as default photos for  front, ingredients, and nutrition)
   Line 22: Line 28:     
===== Parameters =====
 
===== Parameters =====
* code: the barcode
+
* code: the barcode of the product
* imagefield: (front | ingredients | nutrition)
+
* imagefield: (can be either: front | ingredients | nutrition)
* imgupload_front : your image file if imagefield:front
+
* imgupload_front : your image file if imagefield=front
* imgupload_ingredients: your image file if imagefield:ingredients
+
* imgupload_ingredients: your image file if imagefield=ngredients
* imgupload_nutrition: your image file if imagefield:nutrition
+
* imgupload_nutrition: your image file if imagefield=nutrition
 
      
===== Example =====
 
===== Example =====
Line 279: Line 284:  
Values:
 
Values:
 
==== Selecting a photo ====
 
==== Selecting a photo ====
<pre>imgid=</pre>
+
<pre>product_image_crop.pl?code=3266110700910&id=nutrition_fr&imgid=1</pre>
Values:
+
<pre>
 +
id: the field you want to attribute the image to
 +
code: the barcode of the product
 +
imgid: the image id you want to select into the field
 +
</pre>
 +
<pre>
 +
id can be:
 +
front_fr
 +
nutrition_fr
 +
ingredients_fr
 +
 
 +
front_nl
 +
nutrition_nl
 +
ingredients_nl
 +
 
 +
 +
</pre>
 +
<pre>
 +
You retrieve the photo id when you upload it
 +
</pre>
 +
 
 
==== Rotating a photo ====
 
==== Rotating a photo ====
 
<pre>Test server: https://world.openfoodfacts.net/cgi/product_image_rotate.pl</pre>
 
<pre>Test server: https://world.openfoodfacts.net/cgi/product_image_rotate.pl</pre>
<pre>Live server: https://world.openfoodfacts.org/cgi/product_image_rotate.pl</pre>
+
<pre>
 +
Parameters:
 +
</pre>
 
===== Getting the preview =====
 
===== Getting the preview =====
 
Parameters:
 
Parameters:
Line 305: Line 332:  
https://world.openfoodfacts.org/cgi/product_image_crop.pl?code=3266110700910&id=nutrition_fr&imgid=1&angle=90
 
https://world.openfoodfacts.org/cgi/product_image_crop.pl?code=3266110700910&id=nutrition_fr&imgid=1&angle=90
   −
==== Removing background on a photo ("White magic") ====
+
==== Removing background on a photo ====
 
This will work best on photos with a white background. Best use case is to let user try it and give up if the result is not satisfying.
 
This will work best on photos with a white background. Best use case is to let user try it and give up if the result is not satisfying.
 
<pre>white_magic=</pre>
 
<pre>white_magic=</pre>
 
Values:
 
Values:
   −
==== Color correction on a photo ("Normalize")====
+
==== Perform color correction on a photo ====
 
<pre>normalize=</pre>
 
<pre>normalize=</pre>
 
Values:
 
Values:
Line 328: Line 355:  
type = add
 
type = add
 
action = display
 
action = display
imgid =
+
imgid = the id of the source image
x1= the X origin of the crop
+
x1 = the X origin of the crop
y1=the Y origin of the crop
+
y1 = the Y origin of the crop
x2=the X end of the crop
+
x2 = the X end of the crop
y2=the Y end of the crop
+
y2 = the Y end of the crop
 
</pre>
 
</pre>
  

Navigation menu