How does the tool hit an exact KB target?
It runs a binary search over JPEG quality levels, encoding the image repeatedly until it finds the highest quality that still fits your ceiling. If quality alone cannot reach the target, it steps the dimensions down and searches again.