8000 How to add an smaller image into a larger one efficiently? · Issue #247 · kleisauke/net-vips · GitHub
[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add an smaller image into a larger one efficiently? #247

Open
LionelArn2 opened this issue Jan 24, 2025 · 0 comments
Open

How to add an smaller image into a larger one efficiently? #247

LionelArn2 opened this issue Jan 24, 2025 · 0 comments

Comments

@LionelArn2
Copy link

Hi :)

I'm trying to add (and not insert) a small image into a larger one with some XY offset. What I have managed to do so far works as follows:

// Initialize a large image
Image largeImage = Image.Black(10000, 10000);

// Add a small image in the large image (this will be done multiple times)
Image smallImage = Image.Black(100, 100);
Image canvasForSmallImage = Image.Black(10000, 10000).Insert(smallImage, 500, 630);

// Add the canvas containing the small image to the large image
largeImage += canvasForSmallImage;

If we have to add a lot of small images, and we were to save the large image on the disk, I noticed that the process is very slow compared to just inserting the small images, so I'm assuming that libvips is adding the entire canvas to the entire large image, instead of adding only the small image (which makes sense). Is there a way to efficiently do this? (and without loading the entire large image in memory at once)

Thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0