kleisauke / net-vips

.NET binding for libvips.
https://kleisauke.github.io/net-vips/
MIT License
398 stars 32 forks source link

Re: Using Net-Vips in .Net 4.5 project #4

Closed johnmunro-engica closed 6 years ago

johnmunro-engica commented 6 years ago

Hello,

I've been trying to use the Net-Vips solution in .Net 4.5

Is there a way for Net-Vips to use the Vips dll files without setting the Environment Path.

Thanks

John Munro

kleisauke commented 6 years ago

Hello @johnmunro-engica,

NetVips requires .NET Core >= 2.0 or .NET Framework >= 4.6. If this requirement is met, it will need libvips >= 8.2 (8.6.3 is recommended) on your PATH environment variable (if you're running on Windows). I've written a small tutorial about setting up the PATH environment variable here.

If you can't change the PATH environment variable (for a variety of reasons), you could try to copy the content of the vips-x.y.z/bin to the same folder of your executable.

celeronpm commented 6 years ago

When attempting to load the library in a .NET Standard 2.0 library as a nuget reference, nuget downloads the .NET version instead of the standard. Is your target set to core 2.0 or standard 2.0 (which covers core)?

I think the lib can target .NET standard 2.0 instead of .NET core 2.0 right?

kleisauke commented 6 years ago

Hi @celeronpm,

Yes you're right, the library can safely target .NET standard 2.0 instead of .NET core 2.0. Done in https://github.com/kleisauke/net-vips/commit/3e2ad3f1f541fe391321488b893e8883344868a.

If you want to test this, use the nightly version of NetVips. Add the https://ci.appveyor.com/nuget/net-vips feed in the <packageSources> section of your NuGet.config:

<packageSources>
  <add key="netvips-nightly" value="https://ci.appveyor.com/nuget/net-vips" />
</packageSources>

And update NetVips to 1.0.2.72. I will try to make a new release within a few days.

kleisauke commented 6 years ago

@johnmunro-engica Are you able to test the nightly of NetVips? I've lowered the minimum .NET Framework version to 4.5 and packed the latest Windows libvips web binaries into NuGet (so it's not necessary to set the PATH environment variable because the libvips binaries will be copied to the project's output directory).

The installation instructions are above this comment.

johnmunro-engica commented 6 years ago

Hello,

I'll try the new nightly of NetVips as a NuGet

Managed to get an earlier version working using NuGet and working successfully in a .net 4.5 framework project

If it works without requiring the changes to the PATH that will be a big benefit.

One thing I noticed is that in some of the Test Cases the dynamic method name inside the test method had the incorrect name, doesn't cause any issues but is worth improving

kleisauke commented 6 years ago

NetVips versions before 1.0.2 had some bugs, so I can not recommend using a lower version than NetVips 1.0.2 in production. Everything should be fine in 1.0.2, I've tested it under heavy load and no bugs were found.

Thanks for pointing out the naming of the dynamic tests case methods, hopefully this is fixed in https://github.com/kleisauke/net-vips/commit/6ef43faecb107ccf239b54a327ddb0953b2fda08.

johnmunro-engica commented 6 years ago

I used the new latest NuGet with the VIPS dll files included and no need for the environment Path changes which is a big help.

I'm currently using the dzsave for tiling a large image and is working great in the .Net 4.5 project.

I'll take a look at the NET-VIPS project and see if any parts could be tested further or make the code simpler as some methods are long and will post the suggestions to you.

I can see this library being used a lot as the VIPS is a much more powerful and uses a lot less resources than the inbuilt .Net GDI+ for image manipulation and the NET-VIPS is well written and gives lots of access and good summaries to the VIPS methods

celeronpm commented 6 years ago

@kleisauke Thanks for the quick reply.

celeronpm commented 6 years ago

@kleisauke I pulled the .NET 4.5 compatible library you have up on appveyor and tried loading it in a webforms 4.5 project. I get the following error when attempting to touch anything from the library:

The type initializer for '' threw an exception.

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

Stacktracce: at NetVips.Internal.Vips.VipsInit(String argv0) at NetVips.ModuleInitializer.Initialize() at .cctor()

kleisauke commented 6 years ago

@celeronpm I'm sorry, this fell off my radar. The libvips binaries are 64-bit, so make sure you compile with x64 instead of Any CPU.

I will try to make a new release on NuGet with the recent .NET 4.5 / .NET Standard 2.0 compatible changes. The new release will also pack the latest Windows libvips web binary (downloading the libvips binaries and setting up the PATH environment variable are then no longer necessary on Windows).

kleisauke commented 6 years ago

I've just released version 1.0.3 on NuGet which targets .NET Standard 2.0 instead of .NET Core 2.0 and lowered the minimum required .NET Framework version to 4.5.

Also the pre-compiled libvips Windows binary is bundled with this version. It's therefore no longer necessary to download the pre-compiled binary and to set the PATH environment variable. The readme has some remarks about how to disable the bundled libvips and use a different version of libvips.

I'll close this issue for now, please feel free to re-open if there's still a problem.

celeronpm commented 6 years ago

Thanks!

Get Outlook for Androidhttps://aka.ms/ghei36


From: Kleis Auke Wolthuizen notifications@github.com Sent: Wednesday, June 6, 2018 2:09:17 PM To: kleisauke/net-vips Cc: Marius Dornean; Mention Subject: Re: [kleisauke/net-vips] Re: Using Net-Vips in .Net 4.5 project (#4)

Closed #4https://github.com/kleisauke/net-vips/issues/4.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/kleisauke/net-vips/issues/4#event-1667148170, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFic1kjjC9CJeW9XH6Bfzq-WLzLGQv09ks5t6ET9gaJpZM4T2lTh.