def transform(img, source, target, **kwargs):
    cv_image = numpy.array(img)
    shape = cv_image.shape
    snapto8 = (('eightbit_boundary' in kwargs) and (kwargs['eightbit_boundary'] == 'yes'))
    percentageWidth = float(kwargs['percentage_width'])
    percentageHeight = float(kwargs['percentage_height'])
    divisionsWidth = float((kwargs['divisions_width'] if ('divisions_width' in kwargs) else shape[1]))
    divisionsHeight = float((kwargs['divisions_height'] if ('divisions_height' in kwargs) else shape[0]))
    pixelWidth = int((shape[1] * percentageWidth))
    pixelHeight = int((shape[0] * percentageHeight))
    if snapto8:
        pixelWidth = (pixelWidth - (pixelWidth % 8))
        pixelHeight = (pixelHeight - (pixelHeight % 8))
    incrementsWidth = max(8, int((pixelWidth / divisionsWidth)))
    incrementsHeight = max(8, int((pixelHeight / divisionsHeight)))
    crop_x = {'type': 'list', 'values': [i for i in xrange(incrementsWidth, pixelWidth, incrementsWidth)]}
    crop_y = {'type': 'list', 'values': [i for i in xrange(incrementsHeight, pixelHeight, incrementsHeight)]}
    return ({'crop_x': crop_x, 'crop_y': crop_y, 'crop_width': pixelWidth, 'crop_height': pixelHeight}, None)
def transform(img, source, target, **kwargs):
    cv_image = numpy.array(img)
    shape = cv_image.shape
    snapto8 = (('eightbit_boundary' in kwargs) and (kwargs['eightbit_boundary'] == 'yes'))
    percentageWidth = float(kwargs['percentage_width'])
    percentageHeight = float(kwargs['percentage_height'])
    divisionsWidth = float((kwargs['divisions_width'] if ('divisions_width' in kwargs) else shape[1]))
    divisionsHeight = float((kwargs['divisions_height'] if ('divisions_height' in kwargs) else shape[0]))
    pixelWidth = int((shape[1] * percentageWidth))
    pixelHeight = int((shape[0] * percentageHeight))
    if snapto8:
        pixelWidth = (pixelWidth - (pixelWidth % 8))
        pixelHeight = (pixelHeight - (pixelHeight % 8))
    incrementsWidth = max(8, int((pixelWidth / divisionsWidth)))
    incrementsHeight = max(8, int((pixelHeight / divisionsHeight)))
    crop_x = {'type': 'list', 'values': [i for i in xrange(incrementsWidth, pixelWidth, incrementsWidth)]}
    crop_y = {'type': 'list', 'values': [i for i in xrange(incrementsHeight, pixelHeight, incrementsHeight)]}
    return ({'crop_x': crop_x, 'crop_y': crop_y, 'crop_width': pixelWidth, 'crop_height': pixelHeight}, None)