There are plenty of line drawing algorithms to discretize line segments using pixels. The Bresenham's algorithm gives a line where the number of pixels in the segment is the same as its width (in x-direction) or height (y-direction), whichever is largest.
One can also imagine an algorithm where one starts in one of the points, and choose the lattice path between start and end point which minimizes total distance squared of pixel centers to the true geometric line. The number of pixels produced is the width+height, as we have a lattice path.
Note that the (geometric) length of the line segment is somewhere between the number of pixels produced by the two approaches above.
My question is, is there some (standard) algorithm where the number of pixels in the constructed line segment is equal to the the (rounded to nearest integer) length of the line segment? We want the line-segment to be connected, in the sense that every x-coordinate between the endpoints are covered by at least one pixel (and same for y-coordinates).
Of course, one can take the lattice path approach above, and iteratively remove pixels furthest from the true geometric line, but this seems inefficient, and might not guarantee connectednes.