Skip to main content
Participating Frequently
December 20, 2021
Question

(API) Difference between CropAngle and straightenAngle?

  • December 20, 2021
  • 1 reply
  • 1082 views

Hello everyone,

 

I try to crop and straighten images with the Lua SDK.

 

This is the code:

  if LrApplicationView.getCurrentModuleName() == "develop" and photo == catalog:getTargetPhoto() then
    LrDevelopController.setValue("CropLeft", cropLeft)
    LrDevelopController.setValue("CropRight", cropRight)
    LrDevelopController.setValue("CropTop", cropTop)
    LrDevelopController.setValue("CropBottom", cropBottom)
    LrDevelopController.setValue("straightenAngle", angle)
    LrDevelopController.setValue("CropConstrainAspectRatio", aspectRatio)
  else
    local settings = {}
    settings.CropLeft                 = cropLeft
    settings.CropRight                = cropRight
    settings.CropTop                  = cropTop
    settings.CropBottom               = cropBottom
    settings.CropAngle                = -angle
    settings.CropConstrainAspectRatio = aspectRatio
    photo:applyDevelopSettings(settings)
  end

 

The weird thing is that I am getting two different results. When the first if-statement is true the script works fine and the output is as desired: The image was cropped by the calculated values and the angle was corrected while maintaining the desired aspect ratio.

But in the second if-statement the result is different. The image was cropped by the calculated values, but the angle correction changed the desired aspect ratio. Somehow it adds size to the crop width or height.

 

I tried to research it but as far as I know the straightenAngle and CropAngle are supposed to be the same?

 

I tried settings.straightenAngle (instead of settings.CropAngle), but it didn't work at all.

 

Am I missing something here? Do I do something wrong?

 

Thank you all in advance!

This topic has been closed for replies.

1 reply

johnrellis
Legend
December 20, 2021

If you post the exact values for the six crop settings, I'll take a look. I've got a lot of experience with manipulating crops in my Any Crop and Copy Settings plugins.

Ray1980Author
Participating Frequently
December 20, 2021

Hey John, thanks for your reply!

 

So the initial width of the image that I crop is 6240 x 4160 px.

The variables (in this case):

cropLeft = 0.514964809366862

cropRight = 0.8228476092529297

cropTop = 0.18166129150390625

cropBottom = 0.8280794311523437

angle = -1.3169

aspectRatio = true

 

Result of LrDevelopController.setValue-Method: 1921 x 2689 px. (That's the desired aspect ratio of 5/7).

Result of applyDevelopSettings-Method: 1982 x 2644 px. (That's not the desired aspect ratio of 5/7).

 

In both cases I use the same values.

 

When I skip the cropAngle/straightenAngle values, both methods return the desired aspect ratio: they are then both perfectly the same output.

 

Thanks in advance 🙂

johnrellis
Legend
December 20, 2021

I'll dig in late afternoon when I get back to my desk.