//Convert "c:\SomeFolder\InputFile.png" to "c:\SomeFolder\OutputFile.jpg"
using (var imageTask = new ImageTask(@"c:\SomeFolder\InputFile.png"))
imageTask.Save(@"c:\SomeFolder\OutputFile.jpg");
//---------------------------------------
//Convert with a virtual path string:
//See below for other path string examples.
using (var imageTask = new ImageTask("~/SomeFolder/InputFile.png"))
imageTask.Save(@"c:\SomeFolder\OutputFile.jpg");
//Convert with a URL string:
//See below for other path string examples.
using (var imageTask = new ImageTask("http://example.com/SomeFolder/InputFile.png"))
imageTask.Save(@"c:\SomeFolder\OutputFile.jpg");
//Convert with a Data URL string:
//See below for other path string examples.
using (var imageTask = new ImageTask("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"))
imageTask.Save(@"c:\SomeFolder\OutputFile.jpg");
//Convert with a file provider instance:
//See below for other file provider examples (UNC Path, AmazonS3, AzureBlob, Database etc.).
var fileProvider = new FileSystemFileProvider
{
File = "InputFile.png",
Location = new PhysicalLocation
{
Path = @"c:\SomeFolder"
}
};
using (var imageTask = new ImageTask(fileProvider))
imageTask.Save(@"c:\SomeFolder\OutputFile.jpg");
//Convert with a provider string:
//See below for other provider string examples (UNC Path, AmazonS3, AzureBlob, Database etc.).
using (var imageTask = new ImageTask(@"Type=FileSystem; File=InputFile.png; Location='Type=Physical; Path=c:\SomeFolder'"))
imageTask.Save(@"c:\SomeFolder\OutputFile.jpg");
'Convert "c:\SomeFolder\InputFile.png" to "c:\SomeFolder\OutputFile.jpg"
Using imageTask As New ImageTask("c:\SomeFolder\InputFile.png")
imageTask.Save("c:\SomeFolder\OutputFile.jpg")
End Using
'---------------------------------------
'Convert with a virtual path string:
'See below for other path string examples.
Using imageTask As New ImageTask("~/SomeFolder/InputFile.png")
imageTask.Save("c:\SomeFolder\OutputFile.jpg")
End Using
'Convert with a URL string:
'See below for other path string examples.
Using imageTask As New ImageTask("http://example.com/SomeFolder/InputFile.png")
imageTask.Save("c:\SomeFolder\OutputFile.jpg")
End Using
'Convert with a Data URL string:
'See below for other path string examples.
Using imageTask As New ImageTask("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")
imageTask.Save("c:\SomeFolder\OutputFile.jpg")
End Using
'Convert with a file provider instance:
'See below for other file provider examples (UNC Path, AmazonS3, AzureBlob, Database etc.).
Dim fileProvider As New FileSystemFileProvider() With {
.File = "InputFile.png",
.Location = New PhysicalLocation() With {
.Path = "c:\SomeFolder"
}
}
Using imageTask As New ImageTask(fileProvider)
imageTask.Save("c:\SomeFolder\OutputFile.jpg")
End Using
'Convert with a provider string:
'See below for other provider string examples (UNC Path, AmazonS3, AzureBlob, Database etc.).
Using imageTask As New ImageTask("Type=FileSystem; File=InputFile.png; Location='Type=Physical; Path=c:\SomeFolder'")
imageTask.Save("c:\SomeFolder\OutputFile.jpg")
End Using
//Get EXIF thumbnail if exists or resize:
using (var imageTask = new ImageTask(@"C:\Input\Picture1.jpg"))
imageTask.Thumbnail(160).Save(@"C:\Output\Thumbnail1.jpg");
//Just resize:
using (var imageTask = new ImageTask(@"C:\Input\Picture1.jpg"))
imageTask.ResizeWidth(200).Save(@"C:\Output\Picture2.jpg");
'Get EXIF thumbnail if exists or resize:
Using imageTask As New ImageTask("C:\Pictures\Picture1.jpg")
imageTask.Thumbnail(160).Save("C:\Output\Thumbnail1.jpg")
End Using
'Just resize:
Using imageTask As New ImageTask("C:\Pictures\Picture1.jpg")
imageTask.ResizeWidth(200).Save("C:\Output\Picture2.jpg")
End Using
//Using Undo for multiple outputs:
using (var imageTask = new ImageTask(@"C:\Input\Picture1.jpg", enableUndo: true))
imageTask.ResizeWidth(200).Save(@"C:\Output\Picture2.jpg")
.Undo().ResizeHeight(400).Rotate(90).Save(@"C:\Output\Picture3.png")
.UndoAll().Save(outputStream, ImageFormat.Png);
'Using Undo for multiple outputs:
Using imageTask As New ImageTask("C:\Pictures\Picture1.jpg", enableUndo:=True)
imageTask.ResizeWidth(200).Save("C:\Output\Picture2.jpg") _
.Undo().ResizeHeight(400).Rotate(90).Save("C:\Output\Picture3.png") _
.UndoAll().Save(outputStream, ImageFormat.Png)
End Using
//Load image info of "c:\SomeFolder\InputFile.png"
using (var imageInfo = new ImageInfo(@"c:\SomeFolder\InputFile.png"))
{
}
//---------------------------------------
//Load with a virtual path string:
//See below for other path string examples.
using (var imageInfo = new ImageInfo("~/SomeFolder/InputFile.png"))
{
}
//Load with a URL string:
//See below for other path string examples.
using (var imageInfo = new ImageInfo("http://example.com/SomeFolder/InputFile.png"))
{
}
//Load with a Data URL string:
//See below for other path string examples.
using (var imageInfo = new ImageInfo("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"))
{
}
//Load with a file provider instance:
//See below for other file provider examples (UNC Path, AmazonS3, AzureBlob, Database etc.).
var fileProvider = new FileSystemFileProvider
{
File = "InputFile.png",
Location = new PhysicalLocation
{
Path = @"c:\SomeFolder"
}
};
using (var imageInfo = new ImageInfo(fileProvider))
{
}
//Load with a provider string:
//See below for other provider string examples (UNC Path, AmazonS3, AzureBlob, Database etc.).
using (var imageInfo = new ImageInfo(@"Type=FileSystem; File=InputFile.png; Location='Type=Physical; Path=c:\SomeFolder'"))
{
}
'Load image info of "c:\SomeFolder\InputFile.png"
Using imageInfo As New ImageInfo("c:\SomeFolder\InputFile.png")
End Using
'---------------------------------------
'Load with a virtual path string:
'See below for other path string examples.
Using imageInfo As New ImageInfo("~/SomeFolder/InputFile.png")
End Using
'Load with a URL string:
'See below for other path string examples.
Using imageInfo As New ImageInfo("http://example.com/SomeFolder/InputFile.png")
End Using
'Load with a Data URL string:
'See below for other path string examples.
Using imageInfo As New ImageInfo("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")
End Using
'Load with a file provider instance:
'See below for other file provider examples (UNC Path, AmazonS3, AzureBlob, Database etc.).
Dim fileProvider As New FileSystemFileProvider() With {
.File = "InputFile.png",
.Location = New PhysicalLocation() With {
.Path = "c:\SomeFolder"
}
}
Using imageInfo As New ImageInfo(fileProvider)
End Using
'Load with a provider string:
'See below for other provider string examples (UNC Path, AmazonS3, AzureBlob, Database etc.).
Using imageInfo As New ImageInfo("Type=FileSystem; File=InputFile.png; Location='Type=Physical; Path=c:\SomeFolder'")
End Using
//Show all image info including EXIF and IPTC metadata
using (var imageInfo = new ImageInfo(@"C:\Input\Picture1.jpg"))
{
Console.WriteLine("Info:");
Console.WriteLine("----------------------------");
Console.WriteLine("Format: " + imageInfo.Format);
Console.WriteLine("Width: " + imageInfo.Width);
Console.WriteLine("Height: " + imageInfo.Height);
Console.WriteLine("ResolutionX: " + imageInfo.ResolutionX);
Console.WriteLine("ResolutionY: " + imageInfo.ResolutionY);
Console.WriteLine("ColorSpace: " + imageInfo.ColorSpace);
Console.WriteLine("ColorType: " + imageInfo.ColorType);
Console.WriteLine("BitDepth: " + imageInfo.BitDepth);
Console.WriteLine("HasAlpha: " + imageInfo.HasAlpha);
Console.WriteLine("ChannelCount: " + imageInfo.ChannelCount);
Console.WriteLine();
Console.WriteLine("Exif:");
Console.WriteLine("----------------------------");
foreach (var entry in imageInfo.ExifDictionary)
{
Console.WriteLine("Tag: " + entry.Tag);
Console.WriteLine("Value: " + entry.Value);
Console.WriteLine("Description: " + entry.Tag.Description);
Console.WriteLine();
}
Console.WriteLine();
Console.WriteLine("Iptc:");
Console.WriteLine("----------------------------");
foreach (var entry in imageInfo.IptcDictionary)
{
Console.WriteLine("Tag: " + entry.Tag);
Console.WriteLine("Value: " + entry.Value);
Console.WriteLine("Description: " + entry.Tag.Description);
Console.WriteLine();
}
}
'Show all image info including EXIF and IPTC metadata
Using imageInfo As New ImageInfo("C:\Pictures\Picture1.jpg")
Console.WriteLine("Info:")
Console.WriteLine("----------------------------")
Console.WriteLine("Format: " + imageInfo.Format)
Console.WriteLine("Width: " + imageInfo.Width)
Console.WriteLine("Height: " + imageInfo.Height)
Console.WriteLine("ResolutionX: " + imageInfo.ResolutionX)
Console.WriteLine("ResolutionY: " + imageInfo.ResolutionY)
Console.WriteLine("ColorSpace: " + imageInfo.ColorSpace)
Console.WriteLine("ColorType: " + imageInfo.ColorType)
Console.WriteLine("BitDepth: " + imageInfo.BitDepth)
Console.WriteLine("HasAlpha: " + imageInfo.HasAlpha)
Console.WriteLine("ChannelCount: " + imageInfo.ChannelCount)
Console.WriteLine()
Console.WriteLine("Exif:")
Console.WriteLine("----------------------------")
For Each entry In imageInfo.ExifDictionary
Console.WriteLine("Tag: " + entry.Tag.ToString())
Console.WriteLine("Value: " + entry.Value)
Console.WriteLine("Description: " + entry.Tag.Description)
Console.WriteLine()
Next
Console.WriteLine()
Console.WriteLine("Iptc:")
Console.WriteLine("----------------------------")
For Each entry In imageInfo.IptcDictionary
Console.WriteLine("Tag: " + entry.Tag.ToString())
Console.WriteLine("Value: " + entry.Value)
Console.WriteLine("Description: " + entry.Tag.Description)
Console.WriteLine()
Next
End Using
//Show info for a specific EXIF tag:
using (var imageInfo = new ImageInfo(@"C:\Input\Picture1.jpg"))
{
var entry = imageInfo.ExifDictionary[ExifTag.Image.Artist];
Console.WriteLine("Tag: " + entry.Tag);
Console.WriteLine("Value: " + entry.Value);
Console.WriteLine("Description: " + entry.Tag.Description);
Console.WriteLine();
if (imageInfo.ExifDictionary.TryGet(ExifTag.Image.Software, out ExifEntry entry2))
{
Console.WriteLine("Tag: " + entry2.Tag);
Console.WriteLine("Value: " + entry2.Value);
Console.WriteLine("Description: " + entry2.Tag.Description);
Console.WriteLine();
}
}
//Show info for a specific IPTC tag:
using (var imageInfo = new ImageInfo(@"C:\Input\Picture1.jpg"))
{
var entry = imageInfo.IptcDictionary[IptcTag.Application2.Byline];
Console.WriteLine("Tag: " + entry.Tag);
Console.WriteLine("Value: " + entry.Value);
Console.WriteLine("Description: " + entry.Tag.Description);
Console.WriteLine();
if (imageInfo.IptcDictionary.TryGet(IptcTag.Application2.ObjectName, out IptcEntry entry2))
{
Console.WriteLine("Tag: " + entry2.Tag);
Console.WriteLine("Value: " + entry2.Value);
Console.WriteLine("Description: " + entry2.Tag.Description);
Console.WriteLine();
}
if (imageInfo.IptcDictionary.TryGet(IptcTag.Application2.Category, out IptcEntry[] entries))
{
foreach (var entry3 in entries)
{
Console.WriteLine("Tag: " + entry3.Tag);
Console.WriteLine("Value: " + entry3.Value);
Console.WriteLine("Description: " + entry3.Tag.Description);
Console.WriteLine();
}
}
}
'Show info for a specific EXIF tag:
Using imageInfo As New ImageInfo("C:\Input\Picture1.jpg")
Dim entry = imageInfo.ExifDictionary(ExifTag.Image.Artist)
Console.WriteLine("Tag: " + entry.Tag.ToString())
Console.WriteLine("Value: " + entry.Value)
Console.WriteLine("Description: " + entry.Tag.Description)
Console.WriteLine()
Dim entry2 As ExifEntry
If imageInfo.ExifDictionary.TryGet(ExifTag.Image.Software, entry2) Then
Console.WriteLine("Tag: " + entry2.Tag.ToString())
Console.WriteLine("Value: " + entry2.Value)
Console.WriteLine("Description: " + entry2.Tag.Description)
Console.WriteLine()
End If
End Using
'Show info for a specific IPTC tag:
Using imageInfo As New ImageInfo("C:\Input\Picture1.jpg")
Dim entry = imageInfo.IptcDictionary(IptcTag.Application2.Byline)
Console.WriteLine("Tag: " + entry.Tag.ToString())
Console.WriteLine("Value: " + entry.Value)
Console.WriteLine("Description: " + entry.Tag.Description)
Console.WriteLine()
Dim entry2 As IptcEntry
If imageInfo.IptcDictionary.TryGet(IptcTag.Application2.ObjectName, entry2) Then
Console.WriteLine("Tag: " + entry2.Tag.ToString())
Console.WriteLine("Value: " + entry2.Value)
Console.WriteLine("Description: " + entry2.Tag.Description)
Console.WriteLine()
End If
Dim entries As IptcEntry()
If imageInfo.IptcDictionary.TryGet(IptcTag.Application2.Category, entries) Then
For Each entry3 In entries
Console.WriteLine("Tag: " + entry3.Tag.ToString())
Console.WriteLine("Value: " + entry3.Value)
Console.WriteLine("Description: " + entry3.Tag.Description)
Console.WriteLine()
Next
End If
End Using