I want to flip image using apps script. But its not flipping in place. I want to flip in place and not to move the image to a different location. I tried with
function myFunction() {
var image = SlidesApp.getActivePresentation().getSlides()[0].getImages()[0]
image.scaleWidth(-1)
}
The image
The expected
Obtained result
You need to move the position a size:
const t = img.getTransform()
img.setTransform(
t.toBuilder()
.setScaleX(-t.getScaleX())
.setTranslateX(t.getTranslateX() + t.getScaleX() * img.getInherentWidth())
.build()
)
This flips the image by changing the matrix transform. Basically it's the scale and the move by the size of the image.