You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Visual Studio 2022 - windows & docker - IIS express
Description
Hi,
I am doing my first project/POC with Magic.NET and getting an error in web API project .NET 8.0. It's a simple WebAPI template (WeatherForecast) , with add Magick.NET.Core library. We need to generate UMl for Swagger documentation, so we just need to generate some text on the image, nothing special. I check some examples, using imagexxx.Read( "caption: or "label: syntax. to generate text. Can anybody point me to the right direction on how to figure out why I am getting this error in WebAPI, but the code runs fine and generates an image
[Route("images")]
[ApiController]
public class UmlImageController : ControllerBase
{
[Route("uml", Name = "GenarateUmlImage")]
[HttpGet]
public ActionResult GenarateUml([FromQuery] string fullType)
{
using (var images = new MagickImageCollection())
{
var umlClassSettings = new MagickReadSettings
{
FontFamily = "Arial",
FontPointsize = 14,
FontWeight = FontWeight.Bold,
BackgroundColor = MagickColors.AntiqueWhite,
Format = MagickFormat.Png
};
var classType = typeof(ImageContentFilesJsonResponseMessage);
var headerImage = new MagickImage();
headerImage.Read($"caption:{classType.Name}", umlClassSettings); // This line is failing in web app, but in fine in UnitTest
headerImage.Extent(headerImage.BaseWidth + 40, headerImage.BaseHeight + 20, Gravity.Center);
images.Add(headerImage);
ImageMagick.MagickBlobErrorException: UnableToOpenBlob 'caption:ImageContentFilesJsonResponseMessage': No such file or directory @ error/blob.c/OpenBlob/3571
at ImageMagick.NativeInstance.CheckException(IntPtr exception, IntPtr result) in /_/src/Magick.NET/Native/NativeInstance.cs:line 57
at ImageMagick.MagickImage.NativeMagickImage.ReadFile(IMagickSettings`1 settings) in /_/src/Magick.NET/Native/MagickImage.cs:line 6983
at ImageMagick.MagickImage.Read(String fileName, IMagickReadSettings`1 readSettings, Boolean ping) in /_/src/Magick.NET/MagickImage.cs:line 7687
at ImageMagick.MagickImage.Read(String fileName, IMagickReadSettings`1 readSettings) in /_/src/Magick.NET/MagickImage.cs:line 4970
at ImageMagickWebApplication.Controllers.UmlImageController.GenarateUml(String fullType)
Create a template WebAPI .NET project add libraries and controller with code something like this
using (var images = new MagickImageCollection())
{
var umlClassSettings = new MagickReadSettings
{
FontFamily = "Arial",
FontPointsize = 14,
FontWeight = FontWeight.Bold,
BackgroundColor = MagickColors.AntiqueWhite,
Format = MagickFormat.Png
};
var headerImage = new MagickImage();
headerImage.Read($"caption:ImageContentFilesJsonResponseMessage", umlClassSettings); // This line is failing in web app, but in fine in UnitTest
headerImage.Extent(headerImage.BaseWidth + 40, headerImage.BaseHeight + 20, Gravity.Center);
images.Add(headerImage);
and
The text was updated successfully, but these errors were encountered:
No idea why this works in a unit test but you are setting Format to MagickFormat.Png in the umlClassSettings. This means the Read method expects to read an image in the Png format instead of the Caption format.
Magick.NET version
.net 8.0 with latest ImageMagick libraries
Environment (Operating system, version and so on)
Visual Studio 2022 - windows & docker - IIS express
Description
Hi,
I am doing my first project/POC with Magic.NET and getting an error in web API project .NET 8.0. It's a simple WebAPI template (WeatherForecast) , with add Magick.NET.Core library. We need to generate UMl for Swagger documentation, so we just need to generate some text on the image, nothing special. I check some examples, using imagexxx.Read( "caption: or "label: syntax. to generate text. Can anybody point me to the right direction on how to figure out why I am getting this error in WebAPI, but the code runs fine and generates an image
Steps to Reproduce
Create a template WebAPI .NET project add libraries and controller with code something like this
and
The text was updated successfully, but these errors were encountered: