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 do you resize an Image without making a copy? #712

Open
stephane-archer opened this issue Jan 15, 2025 · 6 comments
Open

How do you resize an Image without making a copy? #712

stephane-archer opened this issue Jan 15, 2025 · 6 comments

Comments

@stephane-archer
Copy link

No description provided.

@brendan-duncan
Copy link
Owner

That's currently not possible, it needs the new memory to copy into.

@stephane-archer
Copy link
Author

Can you explain the issue? If you can transform the entire image with imageTransform without creating a new image then Image is mutable.
What is the issue with mutating to a lower resolution?

@brendan-duncan
Copy link
Owner

I'll take a look at doing an in-place minimize function.

@brendan-duncan
Copy link
Owner

Ok, I added a "resize" function, with the same arguments as resizeCopy. It will do the resize within the existing memory of the image as long as the requested size fits into the memory. If the requested size needs more memory, it will fall back to resizeCopy.

@stephane-archer
Copy link
Author

That sounds perfect! 🤩

@brendan-duncan
Copy link
Owner

Keep in mind I haven't tested it a lot. I'm sure there will be edge cases where the wrong pixels will be sampled. Can always go back to it if issues come up, but the solution to those problems would likely be a copy of the memory like resizeCopy so fingers crossed this is good enough.

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

2 participants