in reply to Detect boundaries within .png's - and cropping
Handwavy outline.
- Use Imager to load the image
- Start at the top row. Assume the width of the transparent extent for both left and right is the width of the image; similarly the top and bottom is the height.
- Walk each row and find the length of the transparent extent to the left and right
- If that length is less than the current maximum, remember it as the new current maximum
- At the same time you're going to want to look and make a similar determination for the extent in each column
- After you've walked down each row you know the width of the left most and right most transparent chunks; so crop horizontally from there over. And you should also have the vertical extents as well.
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
---|
In Section
Seekers of Perl Wisdom