The SDK methods photo:rotateLeft() and :rotateRight() have a disastrous bug -- they can rotate all the photos in the catalog. To reproduce:
1. Save the script below into "rotate-bug.lua" in the Scripts folder.
2. Open a test catalog with at least 10 JPEGs.
3. Rename one of the photos to be "xyz321.jpg".
4. Run the script "rotate-bug.lua".
5. Observe that just that one photo gets rotated.
6. Set the filter "Filename Doesn't Contain xyz321.jpg" and observe that file is no longer visible in Grid view.
7. Run the script "rotate-bug.lua".
8. Observe that all the photos in Grid view get rotated!
Underlying this bug is another (old) bug: photo:rotateLeft() and photo:rotateRight() rotate all the photos in the current selection, rather than "photo" (and only "photo"). To work around this old bug, a plugin must use catalog:setSelectedPhotos() to select the photo it wants to rotate. But as this bug report demonstrates, if that photo is not visible in Grid view, all the photos get rotated!
local LrApplication = import "LrApplication"
local LrDialogs = import "LrDialogs"
local catalog = LrApplication.activeCatalog ()
local FileName = "xyz321.jpg"
local photo
for _, p in ipairs (catalog:getAllPhotos ()) do
if p.path:sub (- #FileName) == FileName then
photo = p
break
end
end
if photo == nil then
LrDialogs.message ("Couldn't find photo with file name " .. FileName)
return
end
catalog:setSelectedPhotos (photo, {})
photo:rotateLeft ()
LrDialogs.message ("Remember to Undo!!!")
Tested on LR 11.0.1 / Mac OS 11.6.