A method to create completely customized photo book page templates from scratch in Lightroom 5

Community Beginner ,
Jul 13, 2013

Copy link to clipboard

Copied

I was able to successfully create completely customized Lightroom 5 page templates (including altering the number of, positions, and sizes of pictures) by making edits to the templatePages.lua file(s) in the Lightroom directory tree.  I have never heard of the LUA file format before, but it is ASCII and looks somewhat like XML, so it was fairly easy to decipher.  Here is a high-level description of how I did it.  This applies to Lightroom 5 on Windows 7.  If this doesn't make any sense to you, then don't try it - you're likely in over your head.  Although my description is brief and lacking in detail, it should enable someone who is capable of handling this to figure it out with a little of careful trial and error.  Do this at your own risk - if you screw-up your installation, catalog, or computer, it's your own fault.  It all worked great for me.

First, open the "<lightroom 5 install directory>\Templates\Layout Templates" folder.  Then navigate to the template set that contains the template you would like to use as a starting point for the new template.  For example, "12x12-blurb\clean12x12".  Make a back-up copy of the templatePages.lua file in case you mess something up and want to revert.

There will be a bunch of .jpg files in this directory that each contain a preview image of the layout that carries the same name as the .jpg file.  Find the one that you would like to use as a starting point.  Take note of the name of the file, which is probably something similar to "page_26_preview.jpg".   Duplicate the file and rename it to something unique, such as "dummy_preview.jpg".  It's just temporary, so it doesn't matter what name you pick, provided it is a legal file name with no spaces.

Next, open the templatePages.lua file in a text editor.  I suggest using one that can automatically recognize and format ULA (such as Notepad++, which is open source and free to use).  Then search the file for the unique portion of the file name you took note of earlier, such as "page_26".  It will point you to a section in the LUA file that describes that particular template.  Carefully copy that entire section, including a balanced number of brackets (starting with the two brackets and commas before "children" and ending with the one bracket and comma after the "title" line.  Paste the copied text into the end of the file on a new line immediately following the bracket and comma after the "title" field for the last page template section (right near the end of the file).  Change the "previewName" field to the name of the preview file copy that you created ("dummy_preview.jpg" for me) and the "name" field to the name of the new template you're creating ("dummy" for me, since it is just temporary).  Next change at least one of the hex characters in the "pageID" field such that the new template will have a unique page identifier.

Now you can make edits to the photo and text fields included in the new section, using other templates in the template file as examples.  "x" and "y" fields are coordinates (in pixels) for the bottom-left corner of the picture or text field, "height" and "width" are the width of the field in pixels.  The fields should be mostly self-explanatory, but make sure that the "photoindex" fields are filled-in starting from 1 to N, where N is the number of pictures in the template, with no duplicates or gaps.  They do not need to be in order.  Treat the "textIndex" fields similarly for text fields.  If you want to add an additional picture or text field, simply copy the section describing a picture or text field from another template and paste it, carefully, into the new template that you are creating.

Once you are done, save the file (you may get interference from Windows UAC, in which case save the file elsewhere and the move it back to the correct directory).  Then open Lightroom.  Create a new photobook, and choose the new template for one of the pages, remembering that the preview image will look like the JPG that you copied.  Voila!  If you didn't screw anything up, you should see a page based on your new template.  Then right-click the page and select "Save as custom page", which will cause a fresh preview file to be created for your new template and your template to be copied to the "custom pages" section of the template menu.  The new section you added to the "templatePages.lua" and the "dummy" preview file can now be deleted, since they are no longer needed.  I save them so that I may simply overwrite them the next time I need to create a customized template.

Enjoy, and please share any clarifications, corrections, or enhancements to my process.

Views

50.5K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

A method to create completely customized photo book page templates from scratch in Lightroom 5

Community Beginner ,
Jul 13, 2013

Copy link to clipboard

Copied

I was able to successfully create completely customized Lightroom 5 page templates (including altering the number of, positions, and sizes of pictures) by making edits to the templatePages.lua file(s) in the Lightroom directory tree.  I have never heard of the LUA file format before, but it is ASCII and looks somewhat like XML, so it was fairly easy to decipher.  Here is a high-level description of how I did it.  This applies to Lightroom 5 on Windows 7.  If this doesn't make any sense to you, then don't try it - you're likely in over your head.  Although my description is brief and lacking in detail, it should enable someone who is capable of handling this to figure it out with a little of careful trial and error.  Do this at your own risk - if you screw-up your installation, catalog, or computer, it's your own fault.  It all worked great for me.

First, open the "<lightroom 5 install directory>\Templates\Layout Templates" folder.  Then navigate to the template set that contains the template you would like to use as a starting point for the new template.  For example, "12x12-blurb\clean12x12".  Make a back-up copy of the templatePages.lua file in case you mess something up and want to revert.

There will be a bunch of .jpg files in this directory that each contain a preview image of the layout that carries the same name as the .jpg file.  Find the one that you would like to use as a starting point.  Take note of the name of the file, which is probably something similar to "page_26_preview.jpg".   Duplicate the file and rename it to something unique, such as "dummy_preview.jpg".  It's just temporary, so it doesn't matter what name you pick, provided it is a legal file name with no spaces.

Next, open the templatePages.lua file in a text editor.  I suggest using one that can automatically recognize and format ULA (such as Notepad++, which is open source and free to use).  Then search the file for the unique portion of the file name you took note of earlier, such as "page_26".  It will point you to a section in the LUA file that describes that particular template.  Carefully copy that entire section, including a balanced number of brackets (starting with the two brackets and commas before "children" and ending with the one bracket and comma after the "title" line.  Paste the copied text into the end of the file on a new line immediately following the bracket and comma after the "title" field for the last page template section (right near the end of the file).  Change the "previewName" field to the name of the preview file copy that you created ("dummy_preview.jpg" for me) and the "name" field to the name of the new template you're creating ("dummy" for me, since it is just temporary).  Next change at least one of the hex characters in the "pageID" field such that the new template will have a unique page identifier.

Now you can make edits to the photo and text fields included in the new section, using other templates in the template file as examples.  "x" and "y" fields are coordinates (in pixels) for the bottom-left corner of the picture or text field, "height" and "width" are the width of the field in pixels.  The fields should be mostly self-explanatory, but make sure that the "photoindex" fields are filled-in starting from 1 to N, where N is the number of pictures in the template, with no duplicates or gaps.  They do not need to be in order.  Treat the "textIndex" fields similarly for text fields.  If you want to add an additional picture or text field, simply copy the section describing a picture or text field from another template and paste it, carefully, into the new template that you are creating.

Once you are done, save the file (you may get interference from Windows UAC, in which case save the file elsewhere and the move it back to the correct directory).  Then open Lightroom.  Create a new photobook, and choose the new template for one of the pages, remembering that the preview image will look like the JPG that you copied.  Voila!  If you didn't screw anything up, you should see a page based on your new template.  Then right-click the page and select "Save as custom page", which will cause a fresh preview file to be created for your new template and your template to be copied to the "custom pages" section of the template menu.  The new section you added to the "templatePages.lua" and the "dummy" preview file can now be deleted, since they are no longer needed.  I save them so that I may simply overwrite them the next time I need to create a customized template.

Enjoy, and please share any clarifications, corrections, or enhancements to my process.

Views

50.5K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 13, 2013 3
New Here ,
Oct 24, 2013

Copy link to clipboard

Copied

This post was great!  Thank you so much.  But I am hoping you know one more thing related to this.  In the "transform" section of the definition (where the x/y coordinates are set along with height and width) there is an option called "angle".  I was hoping that changing this value would allow me to offset the angle of the picture.  However, if I put any value there other than 0 the template becomes unusable.

Do you happen to know what this option does?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 24, 2013 0
Mentor ,
Oct 24, 2013

Copy link to clipboard

Copied

DHWachs wrote:

This post was great!  Thank you so much.  But I am hoping you know one more thing related to this.  In the "transform" section of the definition (where the x/y coordinates are set along with height and width) there is an option called "angle".  I was hoping that changing this value would allow me to offset the angle of the picture.  However, if I put any value there other than 0 the template becomes unusable.

Do you happen to know what this option does?

I haven't looked into the files, so this is just a guess based on how some graphic applications work. It's common to think of rotating a shape as pivoting around a center point, but It's possible that the file sets a value for the rotation point not at the center. In some graphics applications, you can set a shape's pivot at any corner or in the middle of any side, of the rectangle that contains the whole shape.

So, your value may be rotating the shape around a pivot that moves the shape into some area that upsets the behavior of other shapes. Just a thought.

HTH

Regards,

Peter

_______________________

Peter Gold

KnowHow ProServices

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 24, 2013 0
Community Beginner ,
Oct 24, 2013

Copy link to clipboard

Copied

peter at knowhowpro wrote:

DHWachs wrote:

This post was great!  Thank you so much.  But I am hoping you know one more thing related to this.  In the "transform" section of the definition (where the x/y coordinates are set along with height and width) there is an option called "angle".  I was hoping that changing this value would allow me to offset the angle of the picture.  However, if I put any value there other than 0 the template becomes unusable.

Do you happen to know what this option does?

I haven't looked into the files, so this is just a guess based on how some graphic applications work. It's common to think of rotating a shape as pivoting around a center point, but It's possible that the file sets a value for the rotation point not at the center. In some graphics applications, you can set a shape's pivot at any corner or in the middle of any side, of the rectangle that contains the whole shape.

So, your value may be rotating the shape around a pivot that moves the shape into some area that upsets the behavior of other shapes. Just a thought.

HTH

Regards,

Peter

_______________________

Peter Gold

KnowHow ProServices

Peter's point is a good one.  I would also assume that the "angle" property allows you to rotate an image, but I haven't tried it myself.  One thing to investigate - are there any page templates included in LR that have image placeholders that are at an angle (I don't recall any, off-hand)?  If so, looking at the associated .lua file could provide insight into how an angled image placeholder should be described.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 24, 2013 0
New Here ,
Oct 25, 2013

Copy link to clipboard

Copied

Unfortunately, there are no image placeholders in all of LR5 for which the pictures are at an angle.  Nor can I find any LUA files which contain an "angle" parameter with a non-zero value.

So far I've tried several values large and small (I've even tried decimal values) but everything causes the template to be no good.

There must be someone out there that knows what all the values in the LUA files represent.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 25, 2013 0
New Here ,
Nov 15, 2013

Copy link to clipboard

Copied

Thanks for telling how to make templates for a book in Lightroom. I was surching for it a long time. And I am gratefull that it works.

Please can you tell me where Lightroom 5 makes the new template when you saved it 'as a custom page'  I want to change something in that new template but I cannot find where is has been saved.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 15, 2013 0
New Here ,
Nov 21, 2013

Copy link to clipboard

Copied

In LR choose the menu "Edit" -> Preferences -> Presets-tab -> Show Lightroom Presets Folders

Probably this will open a folder \AppData\Roaming\Adobe\Lightroom\

There you will find the folder "Layout Templates" containing your custom layouts.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 21, 2013 0
New Here ,
Nov 27, 2013

Copy link to clipboard

Copied

Thanks for your answer, but that is the folder where templates are saved, but the new-made-templates are not there

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 27, 2013 0
New Here ,
Nov 28, 2013

Copy link to clipboard

Copied

I have two folders ... the LR-tamplates are in

"%PROGRAMFILES%\Adobe\Adobe Photoshop Lightroom 5.2\Templates\Layout Templates"

and my custom templates in

"%APPDATA%\Adobe\Lightroom\Layout Templates" (which is the same as above)

and I could edit templates in both folders (and it worked).

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 28, 2013 0
New Here ,
Nov 29, 2013

Copy link to clipboard

Copied

Thanks a lot schleifi ! I found it! Then I can use them again ...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 29, 2013 0
Participant ,
Dec 13, 2013

Copy link to clipboard

Copied

Great findings Mr. MVulovic!

Would it be possible to post some standard format templates like A4 which are hardly missing?

Just a file which can be imported to the preference folder.

That would be very helpful.

Thank you!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 13, 2013 0
Community Beginner ,
Dec 13, 2013

Copy link to clipboard

Copied

Senhay-

I am not sure what printing capabilities Blurb has - they may not support A4 page sizes in photo books.  In any case, I do not have any A4 pages created, so I am sorry that I cannot help you.

-Marko

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 13, 2013 0
Participant ,
Dec 13, 2013

Copy link to clipboard

Copied

Unfortunately LR 5 is not offering any standard formats that are in use in europe and in a lot more countries worldwide.

Because of different aspect ratios there is no work around.

This is to bind the Adobe Customer to the ridiculously high priced blurb service. The prices are the double other providers (germany) charge for the same book.

Worst example is a shipping fee of Euro 17,90 for an express service which is as fast as a local service which only charges 2,95 for the same.

You´ll get this displayed at the end of the ordering process!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 13, 2013 1
New Here ,
Dec 17, 2018

Copy link to clipboard

Copied

Not an expert but would it not be possible to modify the entire templates to fit your needs by applying a change and replace on the sizes and positions using a the ratio of your pages, e.g. replace "height = 909" by "height = 0.3 * 909"? One would only need to replace "height = ", "Height =", "x =", "y =", etc. You should be able to keep all the positions and sizes of the templates this way. One would need to change the size also in the main template LUA file.

I would however make a backup of the templates and keep the files names. You would then need to keep in mind the actual templates sizes.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 17, 2018 0
LEGEND ,
Dec 17, 2018

Copy link to clipboard

Copied

I’m not sure if you can change the built-in templates in LR5 with ease, but this is an interesting thread. In LR Classic it is now possible to create and save your own custom pages and the latest version 8.1 has the ability to snap to grid, making layout more accurate.

I have a quick video demo:

https://youtu.be/o0BuVyoB7N8

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 17, 2018 0
New Here ,
Dec 17, 2018

Copy link to clipboard

Copied

Thanks. That is indeed a useful feature. At my stage, I am already happy with the layout templates book module.

What I do not like is to be limited in the page and cover sizes (all in US and blurb format). I hope that by modifying the LUA using the above method, I could generate PDF books that I can submit to another photo service (WhiteWall in my case). They use the metric system and provide on their webpage the full sizes of their pages and covers (in descriptions similar to what Blurb uses: “Standard Landscape”; “large landscapte”, etc).

WhiteWall is cheaper for the EU and they have actual shops in a few cities.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 17, 2018 0
New Here ,
Jan 22, 2014

Copy link to clipboard

Copied

Great idea! I was finding for it!

If you excuse my poor english, i try to explain a more simple way to do it.

The first is to create a 'custom page' from the standard page you want.

Then you have, in the custom folder (User\app....\Lightroom\Layout Templates\10x8-blurb(or other), a folder 'custompage...' with the 'templatePages.lua' file for your custom page and a jpg file with the preview.

Now you can modify the lua file as MVulovic has explained and the jpg as you want to look like the page.

If you create another custom page for the same dimension book, this is added to the lua file, then you can modify also this one as the first.

In this case you have to do no modify at the original page template.

I hope to haven't write too bad, and to has been helpful.

Tanks

Piero

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 22, 2014 1
Explorer ,
Sep 13, 2014

Copy link to clipboard

Copied

Hello,

I'm very interested in building new templates for Lightroom 5 and have been following the description on this thread.

I found the necessary files and tried editing them.  They should just be Lua script, but instead found binary files.

Below is a screenshot from CodeRunner looking at the file located here:

/Applications/Adobe Photoshop Lightroom 5.app/Contents/PlugIns/layout_toolkit.agmodule/Contents/Resources/13x11-blurb/wedding13x11

I was unclear if this was an odd encoding format or a binary version of Lua.  On further research, Lua is an compiled byte-code language (much like Java).  It can run directly from script but is compiled to byte-code at runtime and runs in a virtual machine.  I found a Lua decompiler (unluac) and was able to decompile the binary to Lua script code.  See second image.

So apparently, Adobe is now storing these Lua files in byte code and not in script form any more.

Did this change recently?

Are there any editors or IDEs that can work directly in Lua byte-code?

Have any others seen this problem?  Is it Mac only?

-Kevin

Screen Shot 2014-09-13 at 2.26.12 PM.pngScreen Shot 2014-09-13 at 2.42.22 PM.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 13, 2014 0