Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for basic HEIC #9

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Sources/ImagePlayground.Examples/Example.ImageEXIF.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ImagePlayground.Examples {
internal partial class Example {
public static void ImageEXIF(string folderPath) {
Console.WriteLine("[*] Comparing two images - showing output");
string filePath1 = System.IO.Path.Combine(folderPath, "IMG_4539.jpeg");

var image = ImagePlayground.Image.Load(filePath1);
if (image.Metadata.ExifProfile != null) {
Console.WriteLine(image.Metadata.ExifProfile.Values);
}

string filePath2 = System.IO.Path.Combine(folderPath, "IMG_4539.HEIC");

image = ImagePlayground.Image.Load(filePath2);
Console.WriteLine(image.Metadata.ExifProfile.Values);

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
<None Update="Images\CalculatorBefore.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Images\IMG_4539.HEIC">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Images\IMG_4539.jpeg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Images\KulekWSluchawkach.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions Sources/ImagePlayground.Examples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ static void Main(string[] args) {
//Example.Charts1(folderPath);
//Example.ResizeImage(folderPath);
//Example.ConvertTo(folderPath);

//Example.ImageModifications1(folderPath);
//Example.ImageModifications2(folderPath);
//Example.ImageTextWatermark(folderPath);
//Example.ImageBGInfo(folderPath);
Example.Combine(folderPath);
Example.ImageEXIF(folderPath);
//Example.Combine(folderPath);
//Example.CreateNewImage(folderPath);
//Example.Compare(folderPath);

// lets open up the folder with the images
//Console.WriteLine("\npress any key to exit the process...");
Expand Down
14 changes: 13 additions & 1 deletion Sources/ImagePlayground/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.IO;
using System.Numerics;
using Codeuctivity.ImageSharpCompare;
using HeyRed.ImageSharp.Heif.Formats.Avif;
using HeyRed.ImageSharp.Heif.Formats.Heif;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing;
using SixLabors.ImageSharp.Drawing.Processing;
Expand Down Expand Up @@ -272,7 +274,17 @@ public static Image Load(string filePath) {
image._filePath = fullPath;

var inStream = System.IO.File.OpenRead(fullPath);
image._image = SixLabors.ImageSharp.Image.Load(inStream);

if (System.IO.Path.GetExtension(fullPath).ToLower() == ".heic") {
var configuration = new Configuration(
new AvifConfigurationModule(),
new HeifConfigurationModule()

);
image._image = SixLabors.ImageSharp.Image.Load(configuration, stream: inStream);
} else {
image._image = SixLabors.ImageSharp.Image.Load(inStream);
}
inStream.Close();
inStream.Dispose();

Expand Down
1 change: 1 addition & 0 deletions Sources/ImagePlayground/ImagePlayground.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<PackageReference Include="Barcoder.Renderer.Image" Version="2.0.0" />
<PackageReference Include="BarcodeReader.ImageSharp" Version="2.0.1" />
<PackageReference Include="Codeuctivity.ImageSharpCompare" Version="2.0.76" />
<PackageReference Include="HeyRed.ImageSharp.Heif" Version="1.0.0" />
<PackageReference Include="QRCoder-ImageSharp" Version="0.9.0" />
<PackageReference Include="ScottPlot" Version="4.1.60" />
<PackageReference Include="SixLabors.Fonts" Version="1.0.0-beta19" />
Expand Down