Exif Information on picture - RealWorld forums

Log-in or register.

Exif Information on picture

Wobbelwap
on November 15th 2013

I'm doing a photography course now and it is really useful to know which settings were used for each photo you made. I was baffled to find that there was no suitable (cheap) software out there that could do that. Luckily RW Paint has Exif information and it can be scripted, so I made the following script:

// shows Exif information
if (Document.EXIF != null && Document.EXIF.Exists)
{
 DrawTool.TEXT(Document, "Arial", 40, 100, 100, "Exposure Time ")
 DrawTool.TEXT(Document, "Arial", 40, 400, 100, Document.EXIF.GetValueByName("ExposureTime"))
 DrawTool.TEXT(Document, "Arial", 40, 100, 145, "F-Number      ")
 DrawTool.TEXT(Document, "Arial", 40, 400, 145, Document.EXIF.GetValueByName("FNumber"))
 DrawTool.TEXT(Document, "Arial", 40, 100, 190, "ISO Value     ")
 DrawTool.TEXT(Document, "Arial", 40, 400, 190, Document.EXIF.GetValueByName("ISOSpeedRatings"))
 DrawTool.TEXT(Document, "Arial", 40, 100, 235, "Date & Time   ")
 DrawTool.TEXT(Document, "Arial", 40, 400, 235, Document.EXIF.GetValueByName("DateTimeOriginal"))
 DrawTool.TEXT(Document, "Arial", 40, 100, 280, "Mode          ")
 DrawTool.TEXT(Document, "Arial", 40, 400, 280, Document.EXIF.GetValueByName("ExposureProgram"));
}

This works fine, but I really would like the script to create a seperate layer with a white background the size of my text. So I can move the text to a suitable position on the photo. Can anyone tell me how to do that?

Vlasta
on November 15th 2013

Creating a layer cannot be done from the preinstalled scripted operations, because the Document that enters those is just the current layer in the layered image. This is due to simplicity - without this, each script would have to contain a part that deals with layers.

You can re-configure the toolbar with the scripted operation and add another button to it and make it work with the whole layered image. It is not hard, but navigating the configuration can be confusing (if you feel adventurous, right-click on the toolbar and select "Configure toolbar" and then add a new command similar to the last one, but do not use the "Document - Extract document part" component). Since this is not the first time someone has encountered similar problems, I have make a video over that demonstrates how to re-configure the toolbar.

Inside this new script, it will be possible to use the Document.LayeredImage accessor to create a new layer like this:

var li = Document.LayeredImage;
var wiz = Application.CreateWizard("35AFBDB5-1B26-4195-8786-83C8E1CBC08E");
wiz.SizeX = li.sizeX;
wiz.SizeY = li.sizeY;
li.CreateLayer(-1, wiz, "35AFBDB5-1B26-4195-8786-83C8E1CBC08E");
var newlayer = li.GetLayer(0);

And then you can go ahead and draw into the new layer by using "newlayer" instead of "Document".

DrawTool.TEXT(newlayer, "Arial", 40, 100, 100, "Exposure Time ");
...

The GUIDs in the code are kind of cryptic, but that is the most effective way and it can be use to create vector layers (by using different IDs). There is a more intuitive way that utilizes Blender.CreateCanvas(...) and li.CopyToLayer(...), but that is slower.

PAEz
on November 16th 2013

Sweet, I keep meaning to ask you how to create a layer.
I put a note in the Layers doc page linking here.

Wobbelwap
on November 18th 2013

It took a while before I figured out that I had to create a button like you explained before on the page about layers. But now the script looks like this and it does what I wanted it to do. Thanks for the help.

// shows Exif information
if (Document.EXIF != null && Document.EXIF.Exists)
{
 var expt = Document.EXIF.GetValueByName("ExposureTime");
 var fnum = Document.EXIF.GetValueByName("FNumber");
 var isos = Document.EXIF.GetValueByName("ISOSpeedRatings");
 var expp = Document.EXIF.GetValueByName("ExposureProgram");
 var dtor = Document.EXIF.GetValueByName("DateTimeOriginal");

 var li = Document.LayeredImage;
 var wiz = Application.CreateWizard("35AFBDB5-1B26-4195-8786-83C8E1CBC08E");
 wiz.SizeX = li.sizeX;
 wiz.SizeY = li.sizeY;
 li.CreateLayer(-1, wiz, "35AFBDB5-1B26-4195-8786-83C8E1CBC08E");
 var newlayer = li.GetLayer(0);
 DrawTool.SetColor1(100, 100, 100, 100);
 DrawTool.RECTANGLE(newlayer, 0, 405, 210, 320, 126);
 DrawTool.SetColor1(0, 0, 0, 100);
 DrawTool.TEXT(newlayer, "Arial", 40, 100, 100, "Exposure Time ");
 DrawTool.TEXT(newlayer, "Arial", 40, 400, 100, expt);
 DrawTool.TEXT(newlayer, "Arial", 40, 100, 145, "F-Number      ");
 DrawTool.TEXT(newlayer, "Arial", 40, 400, 145, fnum);
 DrawTool.TEXT(newlayer, "Arial", 40, 100, 190, "ISO Value     ");
 DrawTool.TEXT(newlayer, "Arial", 40, 400, 190, isos);
 DrawTool.TEXT(newlayer, "Arial", 40, 100, 235, "Mode          ");
 DrawTool.TEXT(newlayer, "Arial", 40, 400, 235, expp);
 DrawTool.TEXT(newlayer, "Arial", 40, 100, 280, "Date & Time   ");
 DrawTool.TEXT(newlayer, "Arial", 40, 400, 280, dtor);
}
Wobbelwap
on November 18th 2013

So the next things I need are:

A command to show both layers, while the new layer is the active one.
A way to keep my new button, the next time I start the programm.

I've seen the SDK, bit out of my league there...

Vlasta
on November 18th 2013

The button should be remembered automatically. But there is a small catch - if you have multiple windows open simultaneously, the last one closed will overwrite the global configuration. So, just make sure that when you are adding the button, you only have one window open and close it (or just the image) after adding the button and it will be there next time you start the program.

Also, since you figured out how to work with the configuration and removed the "Document - Extract Document Part" step, you may also want to get rid of the "Display Configuration" step. That way, you won't have to click on OK each time.

I am not entirely sure what you mean by the first thing ("show both layers"). The new layer should be visible by default. Do you mean you want to select the added layer in the list of layers? If so, try this:

li.PutIndicesToState(Context, "LAYER", 0);

The end of the script is probably the best place. If you want to select both layers, this should do it:

li.PutIndicesToState(Context, "LAYER", [0, 1]);
Wobbelwap
on November 19th 2013

Thanks, both tips worked. Both layers were indeed visible, but I wanted the new layer to be the active one, so I could move it without selecting it first. Otherwise you'd always end up moving the image itself by accident.

I did have multiple windows open yesterday, so that probably caused my button to disappear all the time. I won't make that mistake again.

I will be modifying the new tool in the next few days. I also want to mention this program and the tool to some other photo enthusiasts. But I doubt they will want to enter the script themselves (I can send them a text file and a manual, but still). How can I make the new button portable? And is there a way to make a new icon for it?

Vlasta
on November 19th 2013

Glad to hear that.

There currently is no way to add a custom icon (except writing a plug-in) - you can only select one of the built-in ones for your button. Maybe in future version.

You can export your button - while you are in the configuration, you need to get to the "Command List" step, where it shows the list of buttons. There is a save icon above the list that saves the currently selected one into a .rwcommands file. This file can then be dragged and dropped onto this toolbar to add it back.

Vlasta
on November 20th 2013

The video demonstrating how to reconfigure the toolbar is finally up - here. You have already figured it out, but it may be useful for other people.

I have also re-formatted the code and added {}, which probably somehow got lost.

Wobbelwap
on November 20th 2013

Thanks. Having no experience with JavaScript, I'm not surprised I missed something. But luckily the procedure worked fine without.

I have changed the code a bit to show more data:

//Show Exif information
if (Document.EXIF != null && Document.EXIF.Exists)
{
 var expt = Document.EXIF.GetValueByName("ExposureTime");
 var fnum = Document.EXIF.GetValueByName("FNumber");
 var isos = Document.EXIF.GetValueByName("ISOSpeedRatings");
 var expp = Document.EXIF.GetValueByName("ExposureProgram");
 var dtor = Document.EXIF.GetValueByName("DateTimeOriginal");
 var modl = Document.EXIF.GetValueByName("Model");
 var exbv = Document.EXIF.GetValueByName("ExposureBiasValue");
 var focl = Document.EXIF.GetValueByName("FocalLength");
 var comp = Document.EXIF.GetValueByName("Compression").substring(0,4);
 var fla1 = Document.EXIF.GetValueByName("Flash");
 var fla2 = fla1.indexOf("fired");
 if (fla2 = -1) {var flsh = "no";}
 else {var flsh = "yes";}
 var li = Document.LayeredImage;
 var wiz = Application.CreateWizard("35AFBDB5-1B26-4195-8786-83C8E1CBC08E");
 wiz.SizeX = li.sizeX;
 wiz.SizeY = li.sizeY;
 li.CreateLayer(-1, wiz, "35AFBDB5-1B26-4195-8786-83C8E1CBC08E");
 var newlayer = li.GetLayer(0);
 DrawTool.SetColor1(100, 100, 100, 100);
 DrawTool.RECTANGLE(newlayer, 0, 380, 260, 300, 175);
 DrawTool.SetColor1(0, 0, 0, 100);
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 90, 88, "Date & Time");
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 345, 88, dtor);
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 90, 122, "Model");
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 345, 122, modl);
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 90, 156, "Mode");
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 345, 156, expp);
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 90, 190, "Compresssion");
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 345, 190, comp);
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 90, 224, "Focal Length");
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 345, 224, focl);
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 90, 258, "Exposure Time");
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 345, 258, expt);
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 90, 292, "ISO Value");
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 345, 292, isos);
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 90, 326, "F-Number");
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 345, 326, fnum);
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 90, 360, "Exposure Bias");
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 345, 360, exbv);
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 90, 394, "Flash");
 DrawTool.TEXT(newlayer, "Arial", "BOLD", 40, 345, 394, flsh);
 li.PutIndicesToState(Context, "LAYER", 0);
}
Wobbelwap
on November 20th 2013

I don't think this editor is really suitable for this kind of thing. :-)

PAEz
on November 20th 2013

You need to indent all the lines with code with a space.
http://jsbin.com/ovazew/2
Theres a bookmarklet you can use to make it less painful, just drag that to your bookmarks, select all your code in the post then click that bookmark to have it all indented.

Page views: 1478       Posts: 12      
I wish there were...
Select background
What about ICL files?