I am creating some labels for photographs. The labels will appear in the bottom left of each picture. I want the text to be rendered in a light grey rectangle, and I want the rectangle to be just large enough to contain the text.
The above code produces the label correctly, but places it in a {360, 360} square, even though the text is only about 100px long, and about 30px high. I would like to create a graphic object that is proportional to the size of the text. Is there a way to do this?
This will fail in more places than it works, since ImageSize is not in pixels. Instead, use Rasterize[text, “BoundingBox”] and the result can be used in generating the ImageSize specification.