Bear with me as I'm new to using ImageMagick and couldn't find the answer to this online. I'm dealing with existing code that takes 2 png files and merges them together to form a final png file. Basically an image is going to be printed onto a t-shirt, we receive the image and then merge the file with a template of the t-shirt (or tank top or dress). Everything works fine with the below code. The resulting PNG that gets created though is interlaced (I assume this is due to the merging of the 2 files). The problem I'm having now is we are changing the program that is being used to print these t-shirts. The new program cannot input an interlaced PNG. Is there a setting that I can put into the below code to make sure the final .PNG is not interlaced? I saw where you can include "-interlace none" from the command prompt, but I'm not sure how to incorporate that into my existing code.
Here is what is being used currently:
static void Main(string[] args)
{
using (MagickImage mask = new MagickImage(@"c:\test\maskO2_XS.png"))//black where the cut would be white where the asset is
using (MagickImage image = new MagickImage(@"c:\test\STYLE1_XS_asset_before.png"))//pattern file
{
mask.Resize(image.Width, image.Height);
mask.Density = new Density(150, DensityUnit.PixelsPerInch);
image.Composite(mask, CompositeOperator.Bumpmap);
image.Write(@"c:\test\file_out.png");
}
}
I tested converting the file after the output to a noninterlaced copy of the file and it works, but the amount of time that putting an extra convert into the code would cause issues. I would like to do it all at the same time if possible.
Setting Interlace to None in .NET
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Setting Interlace to None in .NET
I suspect one of your input files is interlaced, so that is carried to the output.
Looking at the source code at https://github.com/dlemstra/Magick.NET/ ... ickImage.c , I would suggest the MagickImage_Interlace_Set() function.
Looking at the source code at https://github.com/dlemstra/Magick.NET/ ... ickImage.c , I would suggest the MagickImage_Interlace_Set() function.
snibgo's IM pages: im.snibgo.com
Re: Setting Interlace to None in .NET
Thanks for the response. It pointed me in the right direction. Strangely enough, both of the input images are noninterlaced but when combined they became interlaced. That may be something in the prior coding though (I didn't write it so I'm not 100% sure).
Anyway, if anyone needs the solution that worked for me, this was the line that I added before the image.Composite line:
image.Interlace = (Interlace.NoInterlace);
Anyway, if anyone needs the solution that worked for me, this was the line that I added before the image.Composite line:
image.Interlace = (Interlace.NoInterlace);