(input_filename)
return img, dpi
Load an image with Pillow and convert it to numpy array. Also
returns the image DPI in x and y as a tuple.
Load an image with Pillow and convert it to numpy array. Also
returns the image DPI in x and y as a tuple.
Load an image with Pillow and convert it to numpy array . Also returns the image DPI in x and y as a tuple .
def load(input_filename):
    '''Load an image with Pillow and convert it to numpy array. Also
returns the image DPI in x and y as a tuple.'''

    try:
        pil_img = Image.open(input_filename)
    except IOError:
        logger.error('warning: error opening {}\n'.format(
            input_filename))
        return None, None

    if pil_img.mode != 'RGB':
        pil_img = pil_img.convert('RGB')

    if 'dpi' in pil_img.info:
        dpi = pil_img.info['dpi']
    else:
        dpi = (300, 300)

    img = np.array(pil_img)

    return img, dpi
def load ( input_filename ) : try : pil_img = Image . open ( input_filename ) except IOError : logger . error ( 'warning: error opening {}\n' . format ( input_filename ) ) return None , None if pil_img . mode != 'RGB' : pil_img = pil_img . convert ( 'RGB' ) if 'dpi' in pil_img . info : dpi = pil_img . info [ 'dpi' ] else : dpi = ( 300 , 300 ) img = np . array ( pil_img ) return img , dpi