Adobe 65007312 Programming Guide - Page 50

Stage 4: Processing rendered photos, Defining post-processing, of rendered photos

Page 50 highlights

CHAPTER 3: Creating Export and Publish Services Adding an export post-process action 50 5. For each filter, if a postProcessRenderedPhotos() function is defined, it is called. The function is called only once, regardless of the number of photos being exported. This function should enter into a loop of the form: for sourceRendition, renditionToSatisfy in filterContext:renditions() do ... end Z The filter context object generates a new rendition request (LrExportRendition) for each of the renditions provided this filter. Z The renditions() iterator provides two values: sourceRendition (the new rendition to be satisfied by the upstream provider) and renditionToSatisfy (the corresponding rendition that this filter is expected to satisfy for its downstream consumer). ADVANCED: If the filter provider wishes to request a different file format than it is expected to satisfy, it can do so using the renditionOptions/filterSettings code snippet shown in "Defining post-processing of rendered photos" on page 46. This might be a good idea as a way to avoid re-encoding (and thus degrading) JPEG files. If you do this, you are still responsible for providing an output file in the exact format and location required by renditionToSatisfy. Z The filter must wait for each rendition to be completed by its upstream provider by calling sourceRendition:waitForRender(). (We will discuss the completion of this loop in Stage 4.) If there is no processRenderedPhotos() function defined by this filter, the filter is simply left out of the loop and all rendition requests instead go to the upstream provider. IMPORTANT: Each filter must generate a photo conforming exactly to the specifications provided to it. In particular, it must provide a suitable photo file in the specified format and at the exact path specified by the downstream consumer. If it cannot do so, it must use renditionToSatisfy:renditionIsDone( false, message ) to indicate why not. It must never provide a file of a different format than that requested. 6. After all of the filters have had an opportunity to intercept the rendition requests, the requests are finally passed to Lightroom's built-in rendering engine. Stage 4: Processing rendered photos As Lightroom completes each rendition request, it signals completion by allowing the corresponding rendition:waitForRender() call to complete. The rendering loops described in stage 3 then finish in top-to-bottom sequence for each photo. For each filter that defines the postProcessRenderedPhotos() function: 1. The waitForRender() call completes, meaning that the upstream provider has completed its attempt to render the photo. If that attempt was successful, a valid photo file conforming to the specifications requested by this filter is present at the path specified by the sourceRendition; that is, specified by this filter when it requested the rendition from its upstream provider. 2. The filter can now do whatever processing it needs to do on that file. This typically means invoking a third-party application using LrTasks.execute(). ADVANCED: If the filter has changed the file format or location on disk using renditionOptions, it must now perform the appropriate operations on the file to convert it so that it now satisfies the request as specified in renditionToSatisfy.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204

C
HAPTER
3: Creating Export and Publish Services
Adding an export post-process action
50
5.
For each filter, if a
postProcessRenderedPhotos()
function is defined, it is called. The function is
called only once, regardless of the number of photos being exported.
This function should enter into a loop of the form:
for sourceRendition, renditionToSatisfy in filterContext:renditions() do ... end
Z
The filter context object generates a new rendition request (
LrExportRendition
) for each of the
renditions provided this filter.
Z
The
renditions()
iterator provides two values:
sourceRendition
(the new rendition to be
satisfied by the upstream provider) and
renditionToSatisfy
(the corresponding rendition that
this filter is expected to satisfy for its downstream consumer).
A
DVANCED
:
If the filter provider wishes to request a different file format than it is expected to satisfy, it can
do so using the
renditionOptions/filterSettings
code snippet shown in
“Defining post-processing
of rendered photos” on page 46
. This might be a good idea as a way to avoid re-encoding (and thus
degrading) JPEG files. If you do this, you are still responsible for providing an output file in the exact format
and location required by
renditionToSatisfy
.
Z
The filter must wait for each rendition to be completed by its upstream provider by calling
sourceRendition:waitForRender()
. (We will discuss the completion of this loop in Stage 4.)
If there is no
processRenderedPhotos()
function defined by this filter, the filter is simply left out of
the loop and all rendition requests instead go to the upstream provider.
I
MPORTANT
:
Each filter must generate a photo conforming exactly to the specifications provided to it. In
particular, it must provide a suitable photo file in the specified format and at the exact path specified by
the downstream consumer. If it cannot do so, it must use
renditionToSatisfy:renditionIsDone(
false,
message
)
to indicate why not. It must never provide a file of a different format than that
requested.
6.
After all of the filters have had an opportunity to intercept the rendition requests, the requests are
finally passed to Lightroom's built-in rendering engine.
Stage 4: Processing rendered photos
As Lightroom completes each rendition request, it signals completion by allowing the corresponding
rendition:waitForRender()
call to complete.
The rendering loops described in stage 3 then finish in top-to-bottom sequence for each photo. For each
filter that defines the
postProcessRenderedPhotos()
function:
1.
The
waitForRender()
call completes, meaning that the upstream provider has completed its attempt
to render the photo. If that attempt was successful, a valid photo file conforming to the specifications
requested by this filter is present at the path specified by the
sourceRendition
; that is, specified by
this filter when it requested the rendition from its upstream provider.
2.
The filter can now do whatever processing it needs to do on that file. This typically means invoking a
third-party application using
LrTasks.execute()
.
A
DVANCED
:
If the filter has changed the file format or location on disk using
renditionOptions
, it must
now perform the appropriate operations on the file to convert it so that it now satisfies the request as
specified in
renditionToSatisfy
.