Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tiled checkerboard behind image with transparency #3

Closed
simonmurdock opened this issue Jan 4, 2016 · 7 comments
Closed

Tiled checkerboard behind image with transparency #3

simonmurdock opened this issue Jan 4, 2016 · 7 comments
Labels

Comments

@simonmurdock
Copy link

I understand IM has this built in via some pattern parameter, but I do not know how to pass this in via Magick.NET.

Or even a way to specify my own checkerboard pattern as a jpg and tile it?

Could you possibly assist? :)

@dlemstra
Copy link
Owner

dlemstra commented Jan 4, 2016

Do you know the command line variant of what you are trying to achieve? Do you want to draw an image over a tiled checkerboard background like Photoshop does?

@simonmurdock
Copy link
Author

I tried some command line variants but had trouble getting those to work how I wanted.

But yes, I want to replicate the photoshop effect where the checkerboard is shown below the transparent areas of the image provided. in this case a .png file. But using my own image for the checkerboard, a 16x16 png file.

The reason I need this is because our gallery web page has a white background, and one client is uploading white logos with a transparent background, making their thumbnails appear invisible.

Thank you

@dlemstra
Copy link
Owner

dlemstra commented Jan 4, 2016

You could also use the MagickImage.ColorAlpha method for and use a color instead of a pattern. But I think you would want to use the Tile method. Your first action has to be to extend the image to as size that it won't show 'half' of your pattern. A 30x20 image would become 32x32 in your case (16x16 pattern). And then you can use the following method logo.Tile(pattern, CompositeOperator.??) I am not sure which operator you would need, prob SrcOver or DstOver.

@simonmurdock
Copy link
Author

I think i was using DstOver in my previous exmaples.

I will give that a go, thanks

update:

transparency_135455_thumb

Here was the code I used:

using (var image = new MagickImage())
{
    image.Read(Files.GetPath(file), settings);

    using (var checkerBoardImage = new MagickImage())
    {
        checkerBoardImage.Read(CheckerboardPath);
        image.BackgroundColor = MagickColor.Transparent;
        image.Tile(checkerBoardImage, CompositeOperator.DstOver);
    }
    image.Write(path); 
}

@simonmurdock
Copy link
Author

Just For my information - is there a methodology to how the API is laid out for Magick.net? Because I can often find a raw imageMagick commandline for what I want to do, but find it very difficult to convert that to a Magick.Net way.

Would it be possible to get some documentation?

@dlemstra
Copy link
Owner

dlemstra commented Jan 5, 2016

Most command line options are methods/properties on the MagickImage class. There are some examples available here: https://magick.codeplex.com/documentation but I agree with you that this project needs more and better documentation. I don't have/make enough time for that.

@simonmurdock
Copy link
Author

ah okay, I might have a go some day
thank you for your help! working nicely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants