public static Picture CreateFromUri(System.Uri uri) { if (uri != null) { byte[] fc; string filename = null; string mimeType = "image/jpeg"; string ext = "jpg"; try { //Uri uriParse = new Uri(uri); //string path = uriParse.LocalPath; string path = uri.LocalPath; filename = System.IO.Path.GetFileName(path); if (filename.Length == 0) { filename = null; } } catch (System.IO.IOException) { } Picture picture = new Picture(); picture.Data = ByteVector.FromUri(uri, out fc, true); if (fc.Length >= 4 && (fc[1] == 'P' && fc[2] == 'N' && fc[3] == 'G')) { mimeType = "image/png"; ext = "png"; } picture.MimeType = mimeType; picture.Type = PictureType.FrontCover; picture.Description = filename == null ? ("cover." + ext) : mimeType; return(picture); } else { throw new ArgumentNullException("uri"); } }