Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

How to enable B&W mode via applying preset programmatically?

New Here ,
Sep 06, 2024 Sep 06, 2024

With latest Lightroom updates I noticed that old logic for applying B&W mode didnt work anymore. But I heard that is possible to do via photo:applyDevelopSettings(). @C.Cella can you please help with this? Some snippet would be really helpfull. 

TOPICS
macOS , SDK , Windows
131
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 06, 2024 Sep 06, 2024
LATEST

@Denys Mostovskyi 

This is the method I use to Apply a Camera Profile.

 

local catalog = import "LrApplication".activeCatalog()
local targetPhoto = catalog:getTargetPhoto()

	-- Check if a Photo is selected.
	-- Optional prevention method from running the code on all photos in the filmstrip if none selected.
	-- These 4 lines below  can be removed and the code will run even if no photo is selected.
	
	if targetPhoto == nil then
	import "LrDialogs".message("No Photo Selected!", "Please sleect a photo.")
		return
	end
	
--
-- Define the Profile settings i.e. "Look" table and appropriate ConvertToGrayscale
--

local profileSettings = {

    Look = {
        Amount = 1,
        Group = {
            ["x-default"] = "Profiles"
        },
        Name = "Adobe Vivid",
        Parameters = {
            CameraProfile = "Adobe Standard",
            Clarity2012 = 10,
            ConvertToGrayscale = false,
            LookTable = "2FE663AB0D3CE5DA7B9F657BBCD66DFE",
            ProcessVersion = 15.4,
            ToneCurveName2012 = "",
            ToneCurvePV2012 = {
                [1] = 0,
                [2] = 0,
                [3] = 32,
                [4] = 22,
                [5] = 64,
                [6] = 56,
                [7] = 128,
                [8] = 128,
                [9] = 224,
                [10] = 232,
                [11] = 240,
                [12] = 246,
                [13] = 255,
                [14] = 255
            },
            ToneCurvePV2012Blue = {},
            ToneCurvePV2012Green = {},
            ToneCurvePV2012Red = {},
            Version = 16.5
        },
        SupportsAmount = false,
        SupportsMonochrome = false,
        SupportsOutputReferred = false,
        UUID = "EA1DE074F188405965EF399C72C221D9"
    },
    
    ConvertToGrayscale = false -- Prfile is color so is "false"", set this to "true" for BW profiles.
}

--
-- Code Task
--

import "LrTasks".startAsyncTask(function()
    catalog:withWriteAccessDo("Profile : Adobe Vivid", function()
    
        local photos = catalog:getTargetPhotos() 

        for _, photo in ipairs(photos) do
        
            -- Apply the Profile settings
            photo:applyDevelopSettings(profileSettings, "Camera Profile : Adobe Vivid") -- proper Histry Step Name, very important !!!
            
            import "LrDialogs".showBezel("Adobe Vivid", 1.5) -- extra visual confirmation on Camera Profile applied
        end
    end)
end)

 

 

 

I chose Adobe Vivid but the same method can be used for any Camera Profile that has "Look" table.

If the Camera Profile has no look table then the method is:

 

 

local profileSettings = {
    Look = {}, -- Remove the Look table
    CameraProfile = "Camera Neutral", -- name of relative Camera or Camera Matching Profile
    ConvertToGrayscale = false --or "true" for BW profiles
}





Hope this helps.


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