Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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 reply to Re: Detect boundaries within .png's - and cropping by Fletch
in thread Detect boundaries within .png's - and cropping by Stickybit

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-16 06:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found