question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Magick.NET does not copy libraries to the correct location on macOS (or Linux)

See original GitHub issue

Magick.NET version

10.1.0

Environment (Operating system, version and so on)

macOS Big Sur 11.6.3

Description

Magick.NET does not copy libraries to the correct location on macOS (or Linux).

When running I get the following error:

Magick.NET-Q8-AnyCPU: The type initializer for 'ImageMagick.MagickFormatInfo' threw an exception.
Magick.NET-Q8-AnyCPU: The type initializer for 'NativeMagickFormatInfo' threw an exception.
Magick.NET-Q8-AnyCPU: Unable to load shared library 'Magick.Native-Q8-x64.dll' or one of its dependencies. 
In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libMagick.Native-Q8-x64.dll, 1): image not found.

It can be solved by (with the output directory as current directory) copying runtimes/osx-x64/native/Magick.Native-Q8-x64.dll.dylib to bin/Magick.Native-Q8-x64.dll.

In my Azure Function Dockerfile that uses this library I have the following in the runtime image which solves the problem there:

RUN cp /home/site/wwwroot/bin/runtimes/linux-x64/native/Magick.Native-Q8-x64.dll.so \
	/home/site/wwwroot/bin/Magick.Native-Q8-x64.dll

This has been an issue for years now, it would be great if a real fix could be implemented. If the project maintainers do not wish to do this, please give me some pointers on where the logic that fixes this should be introduced and I’ll give it a whack.

Steps to Reproduce

Use the Magick.NET package on anything that isn’t Windows.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
dlemstracommented, Aug 24, 2022

I should add an explanation about this to the documentation. You can now do the following in your .csproj file:

<Project>
  <PropertyGroup>
    <MagickCopyNativeLinux>true<MagickCopyNativeLinux>
  </PropertyGroup>
</Project>

And then it should copy the binaries.

1reaction
abjugardcommented, Apr 21, 2022

Well I have issues on my Mac. I use this package in a subproject to an Azure Function, whenever I try to debug the Azure function using the Azure Functions runtime utilities I have to quickly copy the bin/output/runtimes/osx-x64/native/Magick.Native-Q8-x64.dll.dylib to the bin/output/ directory otherwise .NET doesn’t find it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CrossPlatform.md
Getting Magick.NET working on Mono sometimes requires an extra step. The Magick.NET.Native library is not always automatically copied to the output directory ...
Read more >
Calling ImageMagick from C# (.net 6) on OSX
Im trying to use ImageMagick in a C# application on OSX. My constraint is that I'm not allowed to install IM on the...
Read more >
Exception thrown on Linux - Magick.NET
I have the Magick.NET.Native library loading, but the underlying ImageMagick libraries are still failing with 'ImageMagick.
Read more >
ImageMagick – Convert, Edit, or Compose Digital Images
Use ImageMagick® to create, edit, compose, and convert digital images. Resize an image, crop it, change its shades and colors, add captions, and...
Read more >
The magick package: Advanced Image-Processing in R
The magick package provide a modern and simple toolkit for image processing in R. It wraps the ImageMagick STL which is the most ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found