This project has moved. For the latest updates, please go here.

Strange Artifacts in Caption CMYK Image

Feb 15 at 8:33 PM
Edited Feb 16 at 12:35 PM
Hi, I'm getting strange artifacts inside caption on CMYK image, check this screenshot:

Heres the code:
Imports ImageMagick

public class PageClass

    Inherits System.Web.UI.Page

    sub Page_Load(Src as Object, E As EventArgs)

        Response.ContentType = "image/JPEG"

        Dim backgroundImage As New MagickImage("")

        'Uncomment this line for RGB test
        'Dim backgroundImage As New MagickImage("")

        backgroundImage.Quality = 100

        Dim settings As New MagickReadSettings()

        settings.Width = 300
        settings.Height = 200
        settings.FontPointSize = 80
        settings.BackgroundColor = MagickColors.Transparent
        settings.FillColor = new MagickColor(new ColorCMYK(new Percentage(6),new Percentage(7),new Percentage(96),new Percentage(0)))

        'Uncomment this line for RGB test
        'settings.FillColor = new MagickColor("#f2e22b")

        Dim textImage As New MagickImage("caption:test", settings)

        backgroundImage.Composite(textImage, 20, 20, CompositeOperator.Over)

        backgroundImage.Write(Response.OutputStream, MagickFormat.Jpeg)

    end sub

end class
In my tests I discovered that if increase the width considerably the artifacts do not appear.

If you prefer you can download all files here:

Is something I'm doing wrong?
I just need add images over the base/background image, is there other way to do this or composite is the correct option?

Thanks for this library, you're a lifesaver.
Feb 16 at 7:05 PM
Which version of Magick.NET are you using? I am getting the correct result on my machine with the latest version.
Feb 17 at 7:02 PM
Hi dlemstra,

I was using latest version Q8-x86, now I changed to Q16-x86 and all is good, no artifacts.

Thanks for your help.
Feb 17 at 7:34 PM
Edited Feb 17 at 7:35 PM
I also tried to test if I could reproduce your issue with the Q8 build but I am unable to do that. Are you sure you were not using an older version? Or does your code do more than the example that you provided?
Feb 20 at 12:20 PM
Yeah, I'm sure. This code is partially what I'm using, only difference is the remote image on Dropbox is not working, so I have to download the files and working on the server. I downloaded all x86 latest versions. Tried one by one net20, net40, AnyCPU, same problem. Maybe is a hardware problem? I'm working on a cloud server, all stuff are very limited, at least I can have access to the bin folder. For me is okay that Q16 is working, If you want me to try anything else, let me know.
Feb 20 at 5:38 PM
Edited Feb 20 at 5:40 PM
Ouch, Q16 is with these artifacts too. I'm not sure when this is happening, I'll keep testing.
Feb 20 at 8:12 PM
Is it possible that you are sharing the same image in multiple threads? Can you create a solution with a project that I can use to reproduce this issue?
Feb 20 at 8:22 PM
Edited Feb 20 at 8:24 PM
I'm not dealing with multiple threads. Yeah, sure, for what email I can send you a link? I'll prepare the test page.
Feb 20 at 8:28 PM
It would be nice if you could reproduce this in a console application that I can run on my own machine. Or can you only reproduce this on your server?
Feb 20 at 9:05 PM
Edited Feb 20 at 9:18 PM
I can only reproduce on the server. I just checked and the server is 64 bits, but using Magick.NET x86 Library, could be this the issue? I tried to install x64 files and got a error (that I don't remember now..), something that would be need to install, but the host company probably would not install the required components.
Feb 20 at 9:25 PM
That would probably help but I don't know when I will have time to work on it. You can send me the info through CodePlex. The fact that it only fails with CMYK images looks like a strange bug but I don't understand why we cannot reproduce this in a console application.
Feb 21 at 1:42 PM
I think I came to a solution: convert the image to RGB and after to CMYK, hope this don't change anything when print.

Based on docs I did this:
'Convert do RGB

'Write file

'Read and write CMYK file
dim cmykConverter As new MagickImage(Server.MapPath("file.jpg"))
I tried many things to understand why these artifacts show up but I don't came to any solid conclusion, this remembers me a GPU problem in games.
I'm out of time too, so for now this is working.
Feb 21 at 8:51 PM
You are changing the colors when you convert from CMYK to RGB and back. I think it is failing because you are combining the channels of a 3 channel image with a 4 channel image. I still don't understand why I cannot reproduce it though.

What happens when you use TransformColorSpace(ColorProfile.SRGB, ColorProfile.USWebCoatedSWOP) on the textImage and make that CMYK instead of RGB?