Resize to a size limit

The picture is scaled down to the longest edge, then re-encoded at the highest quality that still fits the target. If even the lowest quality is too large, the smallest size it reached is reported so you can lower the edge and try again.

About this tool

Some forms and services cap an upload at five hundred kilobytes or a megabyte. Give this tool the limit and the picture is scaled to fit, then re-encoded at the highest quality that stays under it, with the result shown before you download.

Questions

How is the right quality found?
The encoder is tried at a series of qualities from high to low and stops at the first result that fits. That gives the best-looking file the limit allows rather than a guess.
What if the limit is too small?
The smallest the encoder can produce is reported, along with the quality it used. Lower the longest edge, which removes pixels rather than quality, and try again.
Which format comes out?
JPEG by default, because it is the most widely accepted. With the WebP box ticked the same picture is also encoded as WebP, and whichever of the two is smaller is the one you get.