public static String toBase64(FacesContext context, Resource resource) {
        try {
            return toBase64(context, resource.getInputStream(), resource.getContentType());
        }
        catch (IOException e) {
            throw new FacesException("Could not open InputStream from Resource[library=" + resource.getLibraryName()
                    + ", name=" + resource.getResourceName() + "]", e);
        }
    }
Used to extract resource name (e.g. "#{resource['picture.png'}")
primefaces/src/main/java/org/primefaces/util/ResourceUtils.java