Example #1
0
		/// <summary>
		/// Returns the mime-type of the specified image.
		/// </summary>
		/// <param name="image">The image to retrieve the mime-type for.</param>
		/// <returns>The mime-type of the specified image.</returns>
		/// <exception cref="ArgumentNullException">The image parameter is
		/// null.</exception>
		/// <exception cref="ArgumentException">The mime-type of the specified
		/// image could not be determined.</exception>
		string GetMimeType(Image image) {
			image.ThrowIfNull("image");
			foreach(var codec in ImageCodecInfo.GetImageEncoders()) {
				if (codec.FormatID == image.RawFormat.Guid)
					return codec.MimeType;
			}
			throw new ArgumentException("The mime-type could not be determined.");
		}