http://imagej.273.s1.nabble.com/Scale-bar-macro-problems-tp3695175p3695177.html
the image bar width problem. I didn't realise that it was called for each
efficient.
occured when it tried to process the thumbs.db file. The fact I had no
images open was a red herring. I'll alter my script so it'll only open
images.
> Hi Nick,
>
> in your macro, the "Set Scale..." command is called before
> opening the image, so it will create an error if there is no
> open image at that time.
> You should call it each time after you open an image.
>
> Tiff images have the image scale stored as tags with the image,
> which might cause a scale different from that of the jpegs.
> Again, this problem should be none if you call "Set Scale..."
> after "open".
>
> Michael
> ________________________________________________________________
> Michael Schmid email:
[hidden email]
> Institut fuer Allgemeine Physik, Technische Universitaet Wien
> Wiedner Hauptstr. 8-10/134, A 1040 Wien, Austria
> Tel. +43 1 58801-13452 or -13453, Fax +43 1 58801 13499
> ________________________________________________________________
>
> On 4 Sep 2008, at 16:04, Nick Holway wrote:
>
> Hi,
>>
>> I'm trying to write a macro which puts a scale bar on all the images in a
>> directory. I've borrowed bits from the Bacth Convert macro.
>>
>> run("Set Scale...", "distance=1 known=1 pixel=1 unit=um");
>> dir1 = "C:\\imagejdev\\original\\";
>> dir2 = "C:\\imagejdev\\output\\";
>> list = getFileList(dir1);
>> setBatchMode(true);
>> for (i=0; i<list.length; i++) {
>> showProgress(i+1, list.length);
>> open(dir1+list[i]);
>> run("Scale Bar...", "width=100 height=5 font=18 color=Black
>> background=None
>> location=[Lower Right] bold");
>> saveAs("TIFF", dir2+list[i]);
>> close();
>> }
>>
>> I have a couple of problems with this:
>>
>> * If there is no image open, then a dialog warns you of this
>>
>> * If the macro opens a JPEG then the scrip works properly, if it opens a
>> tif
>> then the scale line extends from the LHS of the image to the RHS of where
>> it
>> should end
>>
>> I'm using the v1.41 of the MBF build on Windows XP SP2 and I also tried
>> Imagej 1.41 with the MBF plugins on Centos 5.2. I had the same problems on
>> both platforms. FWIW the files were originally created under Windows.
>>
>> Does anyone know how to get around these problems?
>>
>> Thanks
>>
>> Nick
>>
>