Hyperion Hyperion - 2 years ago 96
Python Question

Python modules lib.util and lib.geom

I'm using this code to crop some images, but I always get error:

ImportError: No module named lib.util

same for lib.geom. How can I install these modules? I've tried searching on Google but I didn't find anything.

Answer Source

Because those functions were likely made by the author. Check the following links:


# Sorts an array of 4 coordinates, each an array w/ 2 numbers
#  into counter-clockwise order starting from top left


# expects two points vertically separated. If your points are horizontally
#  separated, reverse their x and y when passing into this function
#  output is the angle between the line the two points make and the horizontal

I'm just linking to the same code the author did in his blog.

EDIT: As suggested by @Francesco, you can use the code in those helper functions in many possible ways. Either you copy the functions into your script file and use them directly without import, or you just build modules (or a package) as the author did.

Personally for such a small number of functions I would go with the first way. It's faster and everything remains on the same script file.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download