Just what the title says .
Strictly speaking what I define as "text" bounding box for a grayscaled image is a set of 4 coordinates (x,y,x+width,y+height) that have to define a rectangle area in that image that has the maximum number of non white pixels and at the same time the least possible number of white pixels(without chagning the maximum amount of non-white pixel). I have text in quotation marks since images does not actually contain text because images do only contain pixels with colours.
Having installed ImageMagick in my Ubuntu and typing in the terminal the command: $convert input.png -trim ouput.png
, I get :
Open the two images in new tabs in your web browser and you will understand the difference they have and you will also understand what I define as "text" bounding box. The output.png has actually the width and height that I am looking for.I do not know how to get x and y coordinates.
The answer provided here (1) for pdf pages does not meet my criteria since the "text" bounding box that gs gives me has big white margins ( and actually as far as I can understand what gs defines as "text" bounding box for a pdf is something different from my definition of "text" bounding box for a picture).