hey-red / imagesharp.heif Goto Github PK
View Code? Open in Web Editor NEWHEIF/AVIF decoder for ImageSharp
License: MIT License
HEIF/AVIF decoder for ImageSharp
License: MIT License
And it not compatible with ImageSharp.Heif
Hi,
I was referred from ImageSharp to this package. I am trying to load a heic file with your package and I am getting the following error:
Unable to load DLL 'libheif' or one of its dependencies: The specified module could not be found. (0x8007007E)
Stack trace:
at LibHeifSharp.Interop.LibHeifNative.heif_get_version_number()
at LibHeifSharp.LibHeifInfo.GetLibHeifVersionNumber()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at LibHeifSharp.LibHeifVersion.ThrowIfNotSupported()
at LibHeifSharp.HeifContext..ctor(Stream stream, Boolean leaveOpen)
at HeyRed.ImageSharp.Heif.HeifDecoderCore.Decode[TPixel](Stream stream, CancellationToken cancellationToken)
at HeyRed.ImageSharp.Heif.HeifDecoder.Decode[TPixel](HeifDecoderOptions options, Stream stream, CancellationToken cancellationToken)
at HeyRed.ImageSharp.Heif.HeifDecoder.Decode(HeifDecoderOptions options, Stream stream, CancellationToken cancellationToken)
at SixLabors.ImageSharp.Formats.SpecializedImageDecoder`1.Decode(DecoderOptions options, Stream stream, CancellationToken cancellationToken)
at SixLabors.ImageSharp.Formats.ImageDecoder.<>c__DisplayClass1_0.<Decode>b__0(Stream s)
at SixLabors.ImageSharp.Formats.ImageDecoder.WithSeekableStream[T](DecoderOptions options, Stream stream, Func`2 action)
at SixLabors.ImageSharp.Formats.ImageDecoder.Decode(DecoderOptions options, Stream stream)
at SixLabors.ImageSharp.Image.Load(DecoderOptions options, String path)
at Program.<Main>$(String[] args) in D:\Code\ffng\ConsoleApp1\Program.cs:line 27
Here is my sample program:
using HeyRed.ImageSharp.Heif.Formats.Avif;
using HeyRed.ImageSharp.Heif.Formats.Heif;
using SixLabors.ImageSharp.Formats;
var files = Directory.GetFiles(@"C:\Users\myuser\Downloads\");
var types = new List<string>() { ".jpg", ".jpeg", ".png", ".heic" };
var options = new DecoderOptions()
{
Configuration = new Configuration(
new AvifConfigurationModule(),
new HeifConfigurationModule()
)
};
foreach (var file in files.Where(f => f.Contains("7B44F_bol.heic")))
{
var ext = Path.GetExtension(file);
if (types.Contains(ext))
{
Console.WriteLine(file);
try
{
var image = Image.Load(options , file);
Console.WriteLine(image.Size.ToString());
}
catch (Exception ex)
{
Console.WriteLine($"{file} error {ex.Message}");
}
}
}
Console.ReadLine();
Here are the nuget packages installed:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="HeyRed.ImageSharp.Heif" Version="2.1.1" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.1" />
</ItemGroup>
</Project>
When trying to convert heif images (taken with iPhone 15 pro) to jpg format, we get an error
Invalid input: Unspecified: Metadata not correctly assigned to image
Code snippet which throw an exception
private static async Task<Stream> EditImageInMemoryAsync(Stream orignalImage, Action<IImageProcessingContext> opereation, IImageFormat format)
{
var modifiedImage = new MemoryStream();
using var image = await Image.LoadAsync(orignalImage);
image.Mutate(opereation);
image.Save(modifiedImage, format);
modifiedImage.Position = 0;
orignalImage.Position = 0;
return modifiedImage;
}
Similar issue were fixed in this package.
bad-images.zip - zip file with images. With these images we get an error.
Thanks for this library, very helpful for what I am working on.
I am trying to load an HEIC image using ImageSharp using this library. It works on windows but when I try to load it on android (I am using WSA, haven't gotten a chance to test on actual device but I would imagine it being the same), I get libheif not found
.
I have installed both 'LibHeif.Native.win-x64' and 'LibHeif.Native.linux-x64'. for some reason 'LibHeif.Native' give me errors so I had install both separately.
System.DllNotFoundException: 'libheif'
[HeifDecoderImpl] getSize: not supported!
[HeifDecoderImpl] getSize: not supported!
Loaded assembly: LibHeifSharp.dll [External]
[monodroid-assembly] Shared library 'libheif' not loaded, p/invoke 'heif_get_version_number' may fail
[monodroid-assembly] Shared library 'libheif' not loaded, p/invoke 'heif_get_version_number' may fail
[HeifDecoderImpl] getSize: not supported!
[HeifDecoderImpl] getSize: not supported!
[HeifDecoderImpl] getSize: not supported!
**System.DllNotFoundException:** 'libheif'```
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.