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

Crop empty image spaces #495

Open
sinamcr7 opened this issue Aug 15, 2024 · 2 comments
Open

Crop empty image spaces #495

sinamcr7 opened this issue Aug 15, 2024 · 2 comments

Comments

@sinamcr7
Copy link

is there an option to crop image before saving so the empty spaces with no useful info are removed to reduce file size?
as I'm creating big array at start I need to crop image so empty spaces are removed to save space?

@jcupitt
Copy link
Member

jcupitt commented Aug 15, 2024

Hello @sinamcr7,

Yes, have a look at find_trim:

https://www.libvips.org/API/current/libvips-arithmetic.html#vips-find-trim

$ python
Python 3.12.3 (main, Jul 31 2024, 17:43:48) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvips
>>> x = pyvips.Image.new_from_file("lion.png")
>>> x.width
425
>>> x.height
425
>>> x.find_trim()
[34, 41, 250, 381]
>>> 

@sinamcr7
Copy link
Author

awesome thanks

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