Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Detect boundaries within .png's - and cropping

by Fletch (Bishop)
on Jul 08, 2020 at 07:09 UTC ( [id://11119027]=note: print w/replies, xml ) Need Help??


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.

  • Comment on Re: Detect boundaries within .png's - and cropping

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11119027]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-26 04:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found