facebookincubator/spectrum

Order of operations

juliocbcotta opened this issue · 2 comments

If the developer uses rotate, crop and resize in one transcode request.
In which order multiple operations are executed? It should be in the documentation!

Hi @BugsBunnyBR, the interesting insight is that it does not matter in which order they are executed :) which is a nice property that allows Spectrum to make operation chains more efficient.

  • The crop requirement always logically works on the input image coordinates. I.e. you can imagine it's executed first.
  • The resize requirement gives a guarantee about the output image dimensions. I.e. you can image it's executed last.
  • Hence, the rotation requirement is "logically executed" in between as it neither directly relates to the input and output dimensions.

When actually executing, Spectrum might rotate first or resize first. But then it will transform e.g. the crop requirement that the aforementioned logical model still holds.

As it is not that clear in the docs the developer may think it works in a different way.
The order in which the resize and crop happen is important to plan what operations parameters to use. Thanks for the explanation. It would be great if that is included in the FAQ.