When exporting, specifying the output image in megapixels, it produces bad numbers for width and height.
Examples for images having 3:2 ratio:
 Chose 6 mp, it results in 1999 x 2999. It should be 2000 x 3000;
 Chose 3.84 (to have 2400 x 1600) it is changed to 3.8, results in totally other width/height numbers.
 Chose 1.5 mp, it results in 1499 x 999. It should be 1500 x 2000
The input field should allow numbers up to 4 digits in precision.
Moreover the resulting image dimensions should be calculated with more precision, then rounded, to avoid unexpected numbers.
The expected output for 3:2 ratios would be:
 3000 x 2000 for 6 mp
 2400 x 1600 for 3.84 mp
 1500 x 1000 for 1.5 mp
 3600 x 2400 for 8.64 mp
It's simple math...
Examples for images having 3:2 ratio:
 Chose 6 mp, it results in 1999 x 2999. It should be 2000 x 3000;
 Chose 3.84 (to have 2400 x 1600) it is changed to 3.8, results in totally other width/height numbers.
 Chose 1.5 mp, it results in 1499 x 999. It should be 1500 x 2000
The input field should allow numbers up to 4 digits in precision.
Moreover the resulting image dimensions should be calculated with more precision, then rounded, to avoid unexpected numbers.
The expected output for 3:2 ratios would be:
 3000 x 2000 for 6 mp
 2400 x 1600 for 3.84 mp
 1500 x 1000 for 1.5 mp
 3600 x 2400 for 8.64 mp
It's simple math...
 5 Posts
 2 Reply Likes
Posted 4 months ago
Johan Elzenga, Champion
 1538 Posts
 622 Reply Likes
It all depends on the exact dimensions (exact aspect ratio) of the image you started with. If I export a Sony A7R Mk III image and resize it to 6 Mpixel, I get 2999 x 2000 pixels. If I export a Canon EOS1D X image it becomes 2999 x 1999. My other Canon cameras produce the same 2999 x 2000, but if I export a Sony A7R image it becomes 2998 x 2001.
 310 Posts
 104 Reply Likes
I'm not sure exactly what you're after here, Jozsef. Even simple math runs into precision & rounding issues for numbers that don't divide evenly.
Take a 3:2 ratio image with dimensions of 9000x6000. Making that fit your 6MP definition means you'd have to multiply each dimension by 0.333333. Using the full precision, you'll get your perfect 3000x2000, but reduce the precision by a few decimal places to 0.333 and you'll get 2997x1998.
If you want exact sizes, I think you're better off specifying the dimensions rather than relying on the MP math.
Take a 3:2 ratio image with dimensions of 9000x6000. Making that fit your 6MP definition means you'd have to multiply each dimension by 0.333333. Using the full precision, you'll get your perfect 3000x2000, but reduce the precision by a few decimal places to 0.333 and you'll get 2997x1998.
If you want exact sizes, I think you're better off specifying the dimensions rather than relying on the MP math.
 23 Posts
 5 Reply Likes
If you want exact sizes, I think you're better off specifying the dimensions rather than relying on the MP math.That's what I was thinking. Why go to all that trouble when the easy solution is right in front of you?
John R. Ellis, Champion
 3857 Posts
 1014 Reply Likes
The issue is not one of numerical precision. Rather, as Johan said, the 6 MP 2999 x 1999 issue is caused by the aspect ratio of the original image  some cameras have ratios that are close to but not exactly 3:2.
For example, the Sony A7R III produces images of size 7952 x 5304. These have an aspect ratio of approximately 1.49924585, not 1.5. When you ask LR to export such an image at 6 megapixels, you're asking it to export it at the same aspect ratio as the original (1.49924585). Thus, the exported image is 2999 x 2000, which is the largest size at that aspect ratio that's no larger than 6 MP (*).
Two other cameras with "close" aspect ratios are the the Sony A7R and Pentax K1 II, which are both 7360 x 4912 (1.49837134).
If you want to export at exactly 3:2 with these cameras, you'll have to first crop the image to that ratio in Develop or Library's Quick Develop. You can't do this in Export, which never changes aspect ratio (crops).

(*) Here are forumulas for computing the largest size that's no larger than the specified megapixels:
exported width = round (sqrt (megapixels * 1e6 * width / height))
exported height = floor (megapixels * 1e6 / exported width)
LR appears to use these formulas.
For example, the Sony A7R III produces images of size 7952 x 5304. These have an aspect ratio of approximately 1.49924585, not 1.5. When you ask LR to export such an image at 6 megapixels, you're asking it to export it at the same aspect ratio as the original (1.49924585). Thus, the exported image is 2999 x 2000, which is the largest size at that aspect ratio that's no larger than 6 MP (*).
Two other cameras with "close" aspect ratios are the the Sony A7R and Pentax K1 II, which are both 7360 x 4912 (1.49837134).
If you want to export at exactly 3:2 with these cameras, you'll have to first crop the image to that ratio in Develop or Library's Quick Develop. You can't do this in Export, which never changes aspect ratio (crops).

(*) Here are forumulas for computing the largest size that's no larger than the specified megapixels:
exported width = round (sqrt (megapixels * 1e6 * width / height))
exported height = floor (megapixels * 1e6 / exported width)
LR appears to use these formulas.
(Edited)
 310 Posts
 104 Reply Likes
I still maintain that if you're looking for exact dimensions you shouldn't be relying on the MP setting, making the rest of this more academic than anything, but I don't see your explanation panning out.
Try creating a solid color 9000x6000 image (or 6000x4000 or any dimensions with a 1.5 aspect ratio, for that matter) in Photoshop, import that image into Lightroom and then export with the 6.0 MP setting in the Image sizing section and I'll bet you get a 2999x1999 image.
According to your explanation & formulas, it should come out to be exactly 3000x2000, but it doesn't. Even though they all start out with an aspect ratio of 1.5, the exported image is 2999x1999, which is an aspect ratio of 1.50025.
I certainly could be wrong, but it still seems like precision/rounding is coming into play somewhere.
Try creating a solid color 9000x6000 image (or 6000x4000 or any dimensions with a 1.5 aspect ratio, for that matter) in Photoshop, import that image into Lightroom and then export with the 6.0 MP setting in the Image sizing section and I'll bet you get a 2999x1999 image.
According to your explanation & formulas, it should come out to be exactly 3000x2000, but it doesn't. Even though they all start out with an aspect ratio of 1.5, the exported image is 2999x1999, which is an aspect ratio of 1.50025.
I certainly could be wrong, but it still seems like precision/rounding is coming into play somewhere.
Johan Elzenga, Champion
 1535 Posts
 620 Reply Likes
It’s both. Like I said, my Sony A7R gives a 2998*2001 image in case you export as 6MP. That means that you also won’t get a 3000*2000 image if you use that as export setting. You will get an image that is 2000 pixels on the shortest side, so it will be 2998 (or 2997, I didn’t try it) on the longest side. So I think it is both the aspect ratio as well as rounding errors. The Sony A7R will never produce 2000*3000 pixels, unless you crop first. Other cameras could produce 2000*3000 exactly, but a rounding error makes it 1999*2999.
(Edited)
John R. Ellis, Champion
 3857 Posts
 1014 Reply Likes
Right Tom, I mistakenly focused just on the cameras whose aspect ratio was not exactly 1.5.
John R. Ellis, Champion
 3857 Posts
 1014 Reply Likes
To summarize Jozsef and Johan's points, there are two separate issues:
 Some cameras (e.g. the Sony A7R III) have aspect ratios that are close to but not exactly 1.5. Exporting such images will generally (and correclty) yield sizes that don't have ratio 1.5, since the originals don't have that ratio.
 There is a blatant bug in the megapixels sizing. It's not a "rounding error" inherent in floatingpoint computation, it's just a bug. LR does all of its computation with 64bit floating point numbers, which have much more than the minimum necessary precision. Here's a sample Lua function (LR is written in Lua) that computes the correct exported sizes given a megapixels constraint:
Adobe has struggled with getting correct pixel dimensions before and they generally don't pay attention to these bug reports. One senior employee even claimed incorrectly that the problem with incorrect Crop ratios was inherent in floatingpoint computation. See:
https://feedback.photoshop.com/photoshop_family/topics/lightroom_5_export_isnt_resizing_exactly_to_s...
https://feedback.photoshop.com/photoshop_family/topics/i_cant_add_certain_custom_crop_ratios_in_ligh...
 Some cameras (e.g. the Sony A7R III) have aspect ratios that are close to but not exactly 1.5. Exporting such images will generally (and correclty) yield sizes that don't have ratio 1.5, since the originals don't have that ratio.
 There is a blatant bug in the megapixels sizing. It's not a "rounding error" inherent in floatingpoint computation, it's just a bug. LR does all of its computation with 64bit floating point numbers, which have much more than the minimum necessary precision. Here's a sample Lua function (LR is written in Lua) that computes the correct exported sizes given a megapixels constraint:
function resize (width, height, megapixels)Here's are the results of exporting varioussized test images exported at 6 megapixels, showing the original dimensions and ratio, the exported dimensions, and the dimensions as computed by the correct formula above:
local pixels = megapixels * 1e6
local exportedWidth = math.floor (0.5 + math.sqrt (pixels * width / height))
local exportedHeight = math.floor (pixels / newWidth)
return exportedWidth, exportedHeight
end
Adobe has struggled with getting correct pixel dimensions before and they generally don't pay attention to these bug reports. One senior employee even claimed incorrectly that the problem with incorrect Crop ratios was inherent in floatingpoint computation. See:
https://feedback.photoshop.com/photoshop_family/topics/lightroom_5_export_isnt_resizing_exactly_to_s...
https://feedback.photoshop.com/photoshop_family/topics/i_cant_add_certain_custom_crop_ratios_in_ligh...
Related Categories

Lightroom Classic CC
 13392 Conversations
 2910 Followers