Given an image file href and a set of directories, modify the image file
        name so it's correct with respect to the output and cache directories.

def post_process_symbolizer_image_file(file_href, dirs):
    """ Given an image file href and a set of directories, modify the image file
        name so it's correct with respect to the output and cache directories.
    """
    # support latest mapnik features of auto-detection
    # of image sizes and jpeg reading support...
    # http://trac.mapnik.org/ticket/508

    mapnik_auto_image_support = (MAPNIK_VERSION >= 701)
    mapnik_requires_absolute_paths = (MAPNIK_VERSION < 601)
    file_href = urljoin(dirs.source.rstrip('/')+'/', file_href)
    scheme, n, path, p, q, f = urlparse(file_href)
    if scheme in ('http','https'):
        scheme, path = '', locally_cache_remote_file(file_href, dirs.cache)
    
    if scheme not in ('file', '') or not systempath.exists(un_posix(path)):
        raise Exception("Image file needs to be a working, fetchable resource, not %s" % file_href)
        
    if not mapnik_auto_image_support and not Image:
        raise SystemExit('PIL (Python Imaging Library) is required for handling image data unless you are using PNG inputs and running Mapnik >=0.7.0')

    img = Image.open(un_posix(path))
    
    if mapnik_requires_absolute_paths:
        path = posixpath.realpath(path)
    
    else:
        path = dirs.output_path(path)

    msg('reading symbol: %s' % path)

    image_name, ext = posixpath.splitext(path)
    
    if ext in ('.png', '.tif', '.tiff'):
        output_ext = ext
    else:
        output_ext = '.png'
    
    # new local file name
    dest_file = un_posix('%s%s' % (image_name, output_ext))
    
    if not posixpath.exists(dest_file):
        img.save(dest_file,'PNG')

    msg('Destination file: %s' % dest_file)

    return dest_file, output_ext[1:], img.size[0], img.size[1]