Console Snippets

These are small blocks of code that users can enter in jAlbum’s system console (press F7 or use Menu/Tools/System console to open the console’s window. Paste the code into the top section of the window and then press the ‘Execute’ button. All of the code snippets below are Beanshell unless other wise stated. If another language is used, like JavaScript, then change the scripting language as required. Read more on the system console here

Code Snippets

Using Groovy scrtipting (experimental in 17.1) exclude all images rated less than 3 stars.

currentFolder.descendants.stream().filter(ao -> ao.rating < 3).forEach(ao -> ao.included = false)

To check if your computer’s screen is a ‘HI-DPI’ (High Definition) display or not, use this code

GraphicsUtilities.getScale(window.getGraphicsConfiguration().getDevice());

If the resulting value is greater than 1, then it is a HI-DPI screen.



A way of quickly making an album out of specific flagged images only, for example Red flagged images:

sync = new AlbumSynchronizer(engine);
currentFolder.getDescendants(IncludeOption.EXCLUDED).stream().forEach(ao -> {
  ao.included = ao.folder || ao.flag == Flag.Select;
  if (!ao.included) sync.delete(ao);
})

It will also delete the corresponding excluded images from the album. Values for ‘Flag’ are

None, Red/Select, Yellow/Second, Blue/Review and Green/Approved



If you are having a problem processing an album but don’t get an obvious error message, maybe jAlbum just slows right down, then use:

JAlbum.dumpThreads();

This will create a ‘thread-dump.txt’ file in jAlbum’s configuration folder (use SHIFT + CMD/CNTRL + C to one the folder in your OS).



Here's a quick way to change a published album’s protocol from http to https.

1) Open the relevant album project

2) Open the system console (F7) and execute the following code in the upper panel:

props = rootFolder.getProperties();
albumURL = props.get("albumURL");
props.put("albumURL", albumURL.replace("http:", "https:"));
props.save();