GithubHelp home page GithubHelp logo

0xc0000054 / libheif-sharp Goto Github PK

View Code? Open in Web Editor NEW
54.0 4.0 3.0 2.79 MB

Provides .NET bindings for libheif.

Home Page: https://0xc0000054.github.io/libheif-sharp/

License: GNU Lesser General Public License v3.0

C# 99.97% Batchfile 0.03%
heif heic avif csharp hevc av1 libheif

libheif-sharp's Introduction

libheif-sharp

NuGet version GitHub license

libheif-sharp provides .NET bindings for libheif.
It is built against .NET Standard 2.0, and should work on any supported .NET platform that has a libheif shared library.

Features

  • Supports decoding
    • Top-level images
    • Thumbnails
    • Depth images
    • Vendor-specific auxiliary images
  • Supports encoding
    • Top-level images
    • Thumbnails
  • Supports reading and writing meta-data

Documentation

API Documentation
Building libheif on Windows with vcpkg

Sample Applications

The libheif-sharp-samples repository contains sample applications that demonstrate the use of the library.

Requirements

The libheif shared library must be named libheif in order for it to be found by P/Invoke.
On some platforms a DllImportResolver can be used to customize the loading of the libheif native library.
See LibHeifSharpDllImportResolver.cs in the libheif-sharp-samples repository for an example of this.

The minimum supported libheif version is 1.9.0.

License

This project is licensed under the terms of the GNU Lesser General Public License version 3.0.
See License.md for more information.

libheif-sharp's People

Contributors

0xc0000054 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

libheif-sharp's Issues

Unable to load libheif on .Net Framework

Hi,

I have an issue when HeifContext is being initiated in a .Net Framework 4.6.1 console app. An exception was thrown

An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

StackTrace:
" at LibHeifSharp.Interop.LibHeifNative.heif_get_version_number()\r\n at LibHeifSharp.LibHeifInfo.GetLibHeifVersionNumber()\r\n at System.Lazy1.CreateValue()\r\n at System.Lazy1.LazyInitValue()\r\n at System.Lazy`1.get_Value()\r\n at LibHeifSharp.LibHeifVersion.ThrowIfNotSupported()\r\n at LibHeifSharp.HeifContext..ctor()\r\n at NetFramework.Program.Main(String[] args) in C:\Github\libheif-sharp-samples\NetFramework\Program.cs:line 9"

I create another console app, but it's a .Net Core 3.1 app, and it works fine.
I use the same libheif and libheif-sharp (v2.0.2) for both projects.

Do I need to configure .Net Framework app to make it work with libheif & libheif-sharp?

Add a .NET 7.0 target and a DllImportResolver

Related to #10

This is required for the library to support the Apple mobile/embedded platforms that use AOT (IOS, TvOS, WatchOS).
These platforms have libheif built as a static library and merged into the AOT compiled application.

The DllImportResolver would redirect requests for libheif to the main binary, similar to the following:

if (libName == "libheif")
{
  if (OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsWatchOS())
  {
    return NativeLibrary.GetMainProgramHandle();
  }
}

The DllImportResolver may also be helpful on Windows, where the build system usually defaults to naming the library heif.dll.
If a user forgets to rename heif.dll to libheif.dll, the existing code will throw a DllNotFoundException.
This may not be as critical because the LibHeifSharp readme notes that the native library must be named libheif.

Because the DllImportResolver may be called multiple times for the same native library, the native library handle should be loaded once and cached for future requests.

The DllImportResolver will be registered using a Module Initializer to ensure it is configured before any P/Invokes are called.
It turns out that module initializers are not supported for class libraries. Use a static constructor on the LibHeifNative class?

support for android.

Hi. I am trying to get ImageSharp work with HEIC and have tried hey-red/ImageSharp.Heif#3 and this library. I was wondering about how I can get ARM builds for libheif and the steps to make it work for android

Invalid input: No 'meta' box

Hello,

libheif return for some pictures, this message error when I read avif :
Invalid input: No 'meta' box

Thanks

heif_context_write_to memory

Hello,

it's not a Csharp question, but a C++ question for GNU/Linux for libheif

using heif_context_write_to_file(ctx, ofile.toStringz); a heic file is created,
how to get a byte array instead of create a file ?

thanks

x265 slower

Hello,

I convert a jpg 1792x1792 px 500 ko to heic, it take 7 sec using x265, on Mac using the native class the same jpg take 1 sec to convert to heic, how x265 is slower ?

Thanks

Bundle libheif library in nuget package?

Thanks for this library! I actually started my own wrapper, using SharpGen to automatically generate most of the low-level API bindings, but you've tackled it the hard way, nice ๐Ÿ‘

Do you have a reason (maybe licensing) not to bundle the native DLLs in the nuget package, as described here?

Would you accept a PR that does this?

PS: If you are interested in my project that uses SharpGen, I'll be happy to push it to GitHub

Heic licence

Hello,

to use heic on Windows in my app, is-it necessary to paid a licence ?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.