Coderanger.ImageInfo
0.3.4
dotnet add package Coderanger.ImageInfo --version 0.3.4
NuGet\Install-Package Coderanger.ImageInfo -Version 0.3.4
<PackageReference Include="Coderanger.ImageInfo" Version="0.3.4" />
paket add Coderanger.ImageInfo --version 0.3.4
#r "nuget: Coderanger.ImageInfo, 0.3.4"
// Install Coderanger.ImageInfo as a Cake Addin #addin nuget:?package=Coderanger.ImageInfo&version=0.3.4 // Install Coderanger.ImageInfo as a Cake Tool #tool nuget:?package=Coderanger.ImageInfo&version=0.3.4
Coderanger.ImageInfo
Overview
Coderanger.ImageInfo is a very simple cross-platform dotnet core .netstandard2.1 library that enables you to inspect images and return back their dimensions and metadata.
Supported Formats
Coderanger.ImageInfo is able to decode the dimensions and resolution of the following graphic formats:
- JPEG
- PNG
- WEBP
- BMP (does not support the storage of metadata)
- GIF
Metadata Extraction
Coderanger.ImageInfo can also extract metadata with the following profiles:
- EXIF
- IPTC
- PNG Text
- XMP
Metadata is stored as a Dictionary of Metadata Tag Values against a profile.
It should be noted, however, that XMP data is an exception and is currently stored as a single string Tag Value which contains the unparsed XML, so any parsing of the XMP XML needs to be done outside of this library (for the time being).
Usage
This library is very easy to use; with just a single static method called with an image stream, and the response being either NULL
or an ImageDetails
record containing properties for the various items of image data:
using var imageStream = new FileStream( "image.jpeg", FileMode.Open, FileAccess.Read );
var imageInfo = ImageInfo.Get( imageStream );
if( imageInfo is not null )
{
// If imageInfo was decodable, an object is returned with metadata properties
Debug.WriteLine( $"Width = {imageInfo.Width}" );
Debug.WriteLine( $"Height = {imageInfo.Height}" );
Debug.WriteLine( $"Horizontal DPI = {imageInfo.HorizontalResolution}" );
Debug.WriteLine( $"Vertical DPI = {imageInfo.VerticalResolution}" );
Debug.WriteLine( $"Mime = {imageInfo.MimeType}" );
// If there is any metadata in the image, the 'Tags' property
// will contain the info as a dictionary of profile tag lists
// For example, the following will output the tags in the 'Exif' profile
if( imageInfo.Metadata?.TryGetValue( MetadataProfileType.Exif, out var tags ) ?? false && tags is not null )
{
foreach( var tag in tags )
{
if( tag is not null && tag.HasValue )
{
if( tag.TryGetValue( out var metadataValue ) && metadataValue is not null )
{
Debug.WriteLine( $"{metadataValue.TagName} = {metadataValue.Value}" );
}
}
}
}
}
How can you help?
Contributions are welcome; even if it is just additional test images for subtypes of an image format so that the test suite can be increased.
Find out more on our how to contribute.
Licence
Coderanger.ImageInfo is licensed under the MIT Licence.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.3.4 | 3,404 | 2/7/2022 |