Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to add scale bar to a image for example. I just need to add a bar and a text on top of it to all my images without having to rewrite

Graphics[{Thick, Thick, Yellow, Line[{{100, 100}, {166, 100}}], 
        Text[Style["10 μ", Yellow, Bold, 25], {120, 110}]}]

for every image.

I just want to put this bar and text at left corner of the images I have.


share|improve this question
I'm soooo photogenic! – Dr. belisarius Nov 5 '13 at 1:39
But ... do you want to measure the white bar and resize your yellow scale accordingly? – Dr. belisarius Nov 5 '13 at 1:45
Sorry Yes! I do want to change the numneric as the size of the bar varies. But how can I do that in terms of the horizontal pixel of the image. lets say its a 640x480 image. And a 100 pixels in 640 relates to 10 micron. If I change the bar length to 200 it should show 20. – abhilash sukumari Nov 5 '13 at 1:47
up vote 3 down vote accepted

Provided you have this image is in the same directory that your notebook with the name im.jpg, try this:

im = Import[NotebookDirectory[] <> "im.jpg"];
 Epilog -> 
  Inset[Graphics[{Thick, Thick, Yellow, 
     Line[{{100, 100}, {166, 100}}], 
     Text[Style["10 \[Mu]", Yellow, Bold, 25], {120, 110}]}], 
   Scaled[{0.15, 0.9}]]]

The result is here:enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.