Last active
October 17, 2019 21:55
-
-
Save unitycoder/c7849ab37b7b5851da672c19e316c41f to your computer and use it in GitHub Desktop.
Using ImageMagick with Unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// using ImageMagick with unity : http://1darray.com/blog/2017/01/27/using-imagemagick-with-unity/ | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using ImageMagick; | |
public class ImageMagickTest : MonoBehaviour | |
{ | |
void Start() | |
{ | |
CreateWatermark(); | |
} | |
public void CreateWatermark() | |
{ | |
// our image paths | |
var sourcePath = Application.dataPath + "/Images/FujiFilmFinePixS1Pro.jpg"; | |
var watermarkPath = Application.dataPath + "/Images/Snakeware.png"; | |
// Read image that needs a watermark | |
using (MagickImage image = new MagickImage(sourcePath)) | |
{ | |
// Read the watermark that will be put on top of the image | |
using (MagickImage watermark = new MagickImage(watermarkPath)) | |
{ | |
// Draw the watermark in the bottom right corner | |
image.Composite(watermark, Gravity.Southeast, CompositeOperator.Over); | |
// Optionally make the watermark more transparent | |
watermark.Evaluate(Channels.Alpha, EvaluateOperator.Divide, 4); | |
// Or draw the watermark at a specific location | |
image.Composite(watermark, 200, 50, CompositeOperator.Over); | |
} | |
// Save the result | |
image.Write(Application.dataPath + "/Images/" + "FujiFilmFinePixS1Pro-watermark.jpg"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment