0

我正在尝试将动态高度和固定宽度的图像转换为谷歌幻灯片上的绝对位置,保持 1:1 的纵横比。

例如,我的原始图像可能是(以像素为单位):200x150 或 200x220

我想移动它,使它们都偏移 x:100,y:200,保持原始纵横比,并确保宽度在 PX 中始终固定为相同大小,但高度是可变的。

我正在努力计算正确的变换以进行正确的翻译。

{
'createImage': {
  objectId,
  url,
  elementProperties: {
    pageObjectId,

    size: {
      width: {
        magnitude: (7/9)*originalWidthPx, //pixel to PT conversion
        unit: 'PT',
      },
      height: {
        magnitude: (7/9)*originalHeightPx, //pixel to PT conversion
        unit: 'PT',
      },
    },
    transform: {
      scaleX: 1, // I believe i'll need to scale the image based on Height, keeping the original aspect ratio 
      scaleY: 1,
      translateX: 100, // i dont believe this needs to be dynamic based on w/h
      translateY: 200,
      unit: 'PT',
    },
  }, 
},

}

4

0 回答 0