Open Haruma-VN opened 1 year ago
The affine()
operation is for applying matrix transformations and accepts floats. Did you see the idx
etc. properties for translation offsets?
I want to composite one image to another image created by sharp and using a matrix, using affine and adding odx and ody to the option. However, I'm facing an issue where the image is being cropped if odx exceeds the size of the image being affine. Here is my code:
// matrix(1, 0.5, 0, 1, 32.3, 54.5)
sharp("input.png").affine([1, 0 , 0.5, 1], { background: "#00000000", odx: 32.3, ody: 44.5}).toBuffer().then(image_1 => {
sharp({
create: {
width: 300,
height: 200,
channels: 4,
background: { r: 0, g: 0, b: 0, alpha: 0 }
}
})
.png().composite([{input: image_1, top: 0, left: 0}]).toFile('image_1.png');
});
I have the same issue as this
I've created https://github.com/libvips/libvips/discussions/3454 to discuss this upstream in libvips.
Feature request
What are you trying to achieve?
I want to apply trasform like matrix transfrom in css. EX: matrix(1, 0, 0, 1, 78.8, 22.2). I could use affine for scale and skew in matrix .affine([1, 0], [0, 1]), but when i tried to apply translation by using composite. It throwed error top, left must be int. Do you have anyway that i can use float in composite or special function which can apply matrix