The math behind a photo estimate: grams times per 100 g
One multiplication turns a food name and a weight into calories and macros. Here are its rounding rules, its edge cases and the share of energy formula, with numbers.
Work out your own numbers here, then read where every number comes from.
- Free, no sign up
- 3 photos a day
- Photos never stored
No plate handy? Use a sample
Film strip · this visit · kept on this device only

A photo estimate has one formula: nutrient per 100 g, times grams, divided by 100. Everything else on screen, the totals, the bar and the range, is that formula repeated and added up.
This page walks through the formula, the rounding rules, the way energy shares are calculated and a few edge cases, with numbers from the sample foods in the tool.
The formula
For any food and any weight:
value = USDA value per 100 g, times grams, divided by 100
It works for calories, protein, carbs and fat alike. If rice lists 28.2 g of carbs per 100 g, then 100 g of rice has 28.2 g, 200 g has 56.4 g and 50 g has 14.1 g. The weight is only a scale factor. Double the grams and every number doubles.
The reason the base is 100 g rather than a serving is practical. A serving can be a cup, a slice, a tablespoon or half a package, and it changes from food to food. USDA FoodData Central lists nutrients per 100 g so foods can be compared on one footing, and a multiplication by the weight handles the rest.
Rounding, once per row
Rounding is where small disagreements between calculators come from, so the tool fixes the rule.
- Calories for a row round to a whole number.
- Protein, carbs and fat for a row round to 0.1 g.
- Totals add the rounded rows, then round to the same precision.
Take 25 g of white rice, which carries 130 kcal, 2.69 g protein, 28.2 g carbs and 0.28 g fat per 100 g. Multiplying by 0.25 gives 32.5 kcal, 0.6725 g protein, 7.05 g carbs and 0.07 g fat. The row shows 33 kcal, 0.7 g, 7.1 g and 0.1 g. Notice that 32.5 rounds up to 33, and that 0.07 g of fat shows as 0.1 g, which is a rounding artifact and not a claim that the rice has more fat.
Small rows show this most. One gram of roasted chicken breast is 1.65 kcal, which the row shows as 2 kcal. Real plates have a handful of rows with larger weights, so the rounding effect stays at a few kcal at most.
Since totals add the rounded rows, the number at the top of the card always equals what you get by adding the rows below it. There is no second rounding step hiding between them.
Why we round at the row, not at the end
Rounding only at the end would give a slightly more exact total. It would also give a list that does not add up, which is the kind of thing that makes people doubt a result. The tool picks the second property over the first. A difference of one or two kcal on a plate is smaller than the uncertainty in the weights, so exactness at that level buys nothing.
The energy shares
The split bar shows the share of energy from protein, carbs and fat. It uses the Atwater general factors from FAO Food and Nutrition Paper 77: 4 kcal per gram for protein, 4 for carbs and 9 for fat.
For protein P, carbs C and fat F in grams, first compute the energy total from the macros:
macro energy = 4 times P, plus 4 times C, plus 9 times F
Then the protein share is 400 times P divided by that macro energy, rounded to a whole number. The carbs share is computed the same way. The fat share is 100 minus the other two, so the three always add to 100.
For the sample plate, P is 51.3, C is 61.6 and F is 13.3. The macro energy is 205.2 + 246.4 + 119.7 = 571.3 kcal. Protein is 20,520 divided by 571.3 = 35.9, which rounds to 36. Carbs are 24,640 divided by 571.3 = 43.1, which rounds to 43. Fat takes the remainder, 21.
The card shows 577 kcal while the macros give 571.3. The calorie total comes from the calorie value USDA lists for each food, and the bar comes from the macros. The FAO paper describes more than one system for converting nutrients to energy, so a small gap between the two routes is normal and the tool does not hide it.
Edge cases
A few inputs deserve a rule so the display never breaks.
- A weight of zero, a negative number or a missing number counts as zero grams. The row contributes nothing.
- A food with no matched USDA row has no per 100 g values, so it cannot be multiplied. It is shown with a prompt to pick a food, and you give it numbers by choosing one.
- A bar with no energy shows zero for every share instead of a divide by zero.
These are small rules, but they decide whether a screen stays honest when a photo goes wrong.
Hand checking a row
You can verify any row on the tool with a phone calculator. Open the edit panel for an item and read the match line. It shows the USDA food id, the food name, and the calories, protein, carbs and fat per 100 g. Multiply each by the grams and divide by 100. Compare with the row.
For the roasted chicken breast at 140 g, the match line reads 165 kcal, 31 g protein, 0 g carbs and 3.57 g fat per 100 g. The check is 165 times 1.4 = 231 kcal, 31 times 1.4 = 43.4 g and 3.57 times 1.4 = 4.998 g, shown as 5.0 g. If your arithmetic and the row disagree, that is a bug worth reporting.
What the formula does not know
The formula is exact and the inputs are not. It does not know that a heap of rice can hold more grams than it looks, or that a cooking oil film adds fat the camera cannot see. It does not know whether the USDA row it matched is the one you ate. And the database values are themselves averages: the FoodData Central FAQ notes that values reflect foods sampled at particular times and places.
So treat the math as the reliable half of the estimate. The weights and the matches are the half you can improve, by tapping a box and typing what you know.
Questions people ask
Why per 100 g and not per serving?
A fixed 100 g base makes every food comparable and lets one multiplication handle any weight. Serving sizes vary by food and by label, so they are poor for arithmetic.
Does the tool ever round before the last step?
No. Each row multiplies the exact per 100 g value by the grams and rounds once. The total adds the rounded rows.
What happens if I type zero grams?
A weight of zero, a negative number or something that is not a number counts as zero grams, so the row contributes nothing to the total.
Sources
- USDA Agricultural Research Service. USDA FoodData Central Accessed October 31, 2026.
- Food and Agriculture Organization of the United Nations. Food energy, methods of analysis and conversion factors, chapter 3 (FAO Food and Nutrition Paper 77) Accessed October 31, 2026.
- USDA Agricultural Research Service. FoodData Central frequently asked questions Accessed October 31, 2026.
New Solve Macros articles by email
One email a week with what we published, and nothing in a week with nothing new.