用 updateExportSettings 覆盖图像宽度。

我在 Adobe 论坛上发布了这篇文章。

编写我的第一个 Lightroom 插件,我创建了一个最小的示例,应该在此处设置照片宽度,并包含在下面。但是,我无法使图像成为所指定的 400 x 400。

ExportFilterProvider400.lua:

local LrView = import 'LrView'
local bind   = LrView.bind
--------------------------------------------------------------------------------
-- 此功能将创建在导出会话中添加此过滤器时在导出对话框上显示的部分。

local function sectionForFilterInDialog( f, propertyTable )
  return {
    title = LOC "$$$/SDK/MetaExportFilter/SectionTitle=400x400 Filter",
  }
end

--------------------------------------------------------------------------------
-- 更新导出设置的示例
local function updateExportSettings( exportSettings )
  exportSettings.LR_size_maxHeight = 400
  exportSettings.LR_size_maxWidth  = 400
  exportSettings.LR_size_doConstrain = true
end

--------------------------------------------------------------------------------
return {
sectionForFilterInDialog = sectionForFilterInDialog,
updateExportSettings     = updateExportSettings    , --这个有效吗
}

Info.lua:

return {
  LrSdkVersion        = 3.0,
  LrSdkMinimumVersion = 1.3,
  LrPluginName        = "400x400 Export",
  LrToolkitIdentifier = 'sample.export400x400',

  LrExportFilterProvider = {
    title = LOC "$$$/SDK/MetaExportFilter/Sample=400x400 Size", -- 出现在 LR 导出对话框中导出过滤器部分的字符串
    file  = 'ExportFilterProvider400.lua', -- 包含过滤器定义脚本的文件名
    id    = "metadata1",  -- 导出过滤器的唯一标识符
  },

  VERSION = { major=5, minor=0, revision=0, build=907681, },
}

Adobe Lightroom 可以加载插件并将其添加到导出会话中,但是 updateExportSettings 似乎没有生效。在 Lightroom 5.3 中测试。

点赞
用户97073
用户97073

Rob Cole在Adobe SDK论坛上指出,updateExportSettings被“导出服务提供商”用于预设导出设置。

“导出过滤器提供商”应该使用renditionOptions作为postProcessRenderedPhotos的一部分。

经过一些试验,我有了这个最小的例子, Info.lua(无改变):

return {
  LrSdkVersion        = 3.0,
  LrSdkMinimumVersion = 1.3, -- minimum SDK version required by this plugin
  LrPluginName        = "400x400 Export",
  LrToolkitIdentifier = 'sample.export400x400',

  LrExportFilterProvider = {
    title = LOC "$$$/SDK/MetaExportFilter/Sample=400x400 Size",
    file  = 'ExportFilterProvider400.lua',
    id    = "metadata1",  -- unique identifier for export filter
  },
  VERSION = { major=5, minor=0, revision=0, build=907681, },
}

ExportFilterProvider400.lua

local LrView = import 'LrView'
local bind   = LrView.bind

local function sectionForFilterInDialog( f, propertyTable )
  logger:info('Called sectionForFilterInDialog')
  return {
    title = LOC "$$$/SDK/MetaExportFilter/SectionTitle=400x400 Filter",
  }
end

local function postProcessRenderedPhotos( functionContext, filterContext )
  local renditionOptions = {
    filterSettings = function( renditionToSatisfy, exportSettings )
      exportSettings.LR_size_maxHeight = 400
      exportSettings.LR_size_maxWidth  = 400
      exportSettings.LR_size_doConstrain = true
    end
  }

  for sourceRendition, renditionToSatisfy in filterContext:renditions( renditionOptions ) do
    -- Wait for the upstream task to finish its work on this photo.
    local success, pathOrMessage = sourceRendition:waitForRender()
  end
end
--------------------------------------------------------------------------------

return {
  sectionForFilterInDialog  = sectionForFilterInDialog,
  postProcessRenderedPhotos = postProcessRenderedPhotos,
}
2014-04-08 21:53:19