All pastes #49266 Raw Edit

Stuff

public python v1 · immutable
#49266 ·published 2006-04-13 16:23 UTC
rendered paste body
    def _handle_resize(self, img, tx, ty):        # See docs/cases.txt for logic        ix = img.size[0]        iy = img.size[1]        ir = float(ix) / iy        tr = float(tx) / ty        if (ir < 1 and tr >= 1) or (ir > 1 and tr <= 1) or (ir == 1):            if ir > tr: # (A)                img = img.resize(tx, int(tx / ir))            else: # (B)                img = img.resize(int(ty * ir), ty)        else:            if ir > tr: # (C)                img = img.resize(ty, int(ty / ir))            else: # (D)                img = img.resize(int(tx * ir), tx)