Getting Started with Watermarking SDK - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

Getting Started with Watermarking SDK

  • Home
  • /
  • Getting Started with Watermarking SDK

To view the documentation for the SDK go to Start > All Programs > Bytescout Watermarking SDK and click the “Documentation” link.

The SDK comes with lot of ready-to-use source code examples for Visual Basic, C# and ASP.NET.

To find source code samples please go to “My Documents” folder, “ByteScout Samples” and “Watermarking SDK”. Do not hesitate to copy and paste code snippets from samples right into your application!

The First Application

To help you get the most out of your evaluation, here is the quick guide on protecting images with visible watermarks in your application.

  • Run Visual Studio and create New Project
  • add reference to Bytescout Watermarking SDK using Project | Add Reference. In the Add Reference dialog select “Bytescout.Watermarking” and click OK.
  • copy-and-paste the following code:

Visual Basic:

Imports <span data-scayt_word="System.Diagnostics" data-scaytid="291">System.Diagnostics</span>
Imports <span data-scayt_word="Bytescout.Watermarking" data-scaytid="289">Bytescout.Watermarking</span>
Imports <span data-scayt_word="Bytescout.Watermarking.Presets" data-scaytid="293">Bytescout.Watermarking.Presets</span>


Module <span data-scayt_word="Module1" data-scaytid="295">Module1</span>

Sub Main()
' Create new <span data-scayt_word="watermarker" data-scaytid="296">watermarker</span>
Dim <span data-scayt_word="waterMarker" data-scaytid="299">waterMarker</span> As New <span data-scayt_word="Watermarker" data-scaytid="301">Watermarker</span>()
' Create new preset
Dim preset As New <span data-scayt_word="TextFitsPage" data-scaytid="305">TextFitsPage</span>()
' Create new string
Dim <span data-scayt_word="inputFilePath" data-scaytid="308">inputFilePath</span> As String
' Create new string
Dim <span data-scayt_word="outputFilePath" data-scaytid="313">outputFilePath</span> As String

' Set input file path
<span data-scayt_word="inputFilePath" data-scaytid="309">inputFilePath</span> = "<span data-scayt_word="my_sample_image.jpg" data-scaytid="320">my_sample_image.jpg</span>"
' Set output file path
<span data-scayt_word="outputFilePath" data-scaytid="314">outputFilePath</span> = "<span data-scayt_word="my_sample_output.jpg" data-scaytid="322">my_sample_output.jpg</span>"

' Initialize library
<span data-scayt_word="waterMarker.InitLibrary" data-scaytid="324">waterMarker.InitLibrary</span>("demo", "demo")

' Add image to apply watermarks to
<span data-scayt_word="waterMarker.AddInputFile" data-scaytid="326">waterMarker.AddInputFile</span>(<span data-scayt_word="inputFilePath" data-scaytid="310">inputFilePath</span>, <span data-scayt_word="outputFilePath" data-scaytid="315">outputFilePath</span>)

' Set preset text
<span data-scayt_word="preset.Text" data-scaytid="328">preset.Text</span> = "<span data-scayt_word="Bytescout" data-scaytid="283">Bytescout</span> Watermarking"

' Add watermark to <span data-scayt_word="watermarker" data-scaytid="297">watermarker</span>
<span data-scayt_word="waterMarker.AddWatermark" data-scaytid="330">waterMarker.AddWatermark</span>(preset)

' Set output directory
<span data-scayt_word="waterMarker.OutputOptions.OutputDirectory" data-scaytid="332">waterMarker.OutputOptions.OutputDirectory</span> = "."

' Apply watermarks
<span data-scayt_word="waterMarker.Execute" data-scaytid="334">waterMarker.Execute</span>()

' Open generated image file in default image viewer installed in Windows
<span data-scayt_word="Process.Start" data-scaytid="336">Process.Start</span>(<span data-scayt_word="outputFilePath" data-scaytid="316">outputFilePath</span>)

End Sub

End Module

C#:

using System;
using <span data-scayt_word="System.Diagnostics" data-scaytid="292">System.Diagnostics</span>;
using <span data-scayt_word="System.Drawing" data-scaytid="338">System.Drawing</span>;
using <span data-scayt_word="System.Collections.Generic" data-scaytid="339">System.Collections.Generic</span>;
using <span data-scayt_word="Bytescout.Watermarking" data-scaytid="290">Bytescout.Watermarking</span>;
using <span data-scayt_word="Bytescout.Watermarking.Presets" data-scaytid="294">Bytescout.Watermarking.Presets</span>;

<span data-scayt_word="namespace" data-scaytid="340">namespace</span> Sample
{
class Program
{
static void Main(string[] <span data-scayt_word="args" data-scaytid="341">args</span>)
{
// Create <span data-scayt_word="Watermarker" data-scaytid="302">Watermarker</span> instance
<span data-scayt_word="Watermarker" data-scaytid="303">Watermarker</span> <span data-scayt_word="waterMarker" data-scaytid="300">waterMarker</span> = new <span data-scayt_word="Watermarker" data-scaytid="304">Watermarker</span>();

// Initialize library
<span data-scayt_word="waterMarker.InitLibrary" data-scaytid="325">waterMarker.InitLibrary</span>("demo", "demo");

// Set input file name
string <span data-scayt_word="inputFilePath" data-scaytid="311">inputFilePath</span> = "<span data-scayt_word="my_sample_image.jpg" data-scaytid="321">my_sample_image.jpg</span>";
// Set output file title
string <span data-scayt_word="outputFilePath" data-scaytid="317">outputFilePath</span> = "<span data-scayt_word="my_sample_output.jpg" data-scaytid="323">my_sample_output.jpg</span>";

// Add image to apply watermarks to
<span data-scayt_word="waterMarker.AddInputFile" data-scaytid="327">waterMarker.AddInputFile</span>(<span data-scayt_word="inputFilePath" data-scaytid="312">inputFilePath</span>, <span data-scayt_word="outputFilePath" data-scaytid="318">outputFilePath</span>);

// Create new watermark
<span data-scayt_word="TextFitsPage" data-scaytid="306">TextFitsPage</span> preset = new <span data-scayt_word="TextFitsPage" data-scaytid="307">TextFitsPage</span>();

// Set watermark text
<span data-scayt_word="preset.Text" data-scaytid="329">preset.Text</span> = "<span data-scayt_word="Bytescout" data-scaytid="284">Bytescout</span> Watermarking";

// Add watermark to <span data-scayt_word="watermarker" data-scaytid="298">watermarker</span>
<span data-scayt_word="waterMarker.AddWatermark" data-scaytid="331">waterMarker.AddWatermark</span>(preset);

// Set output directory
<span data-scayt_word="waterMarker.OutputOptions.OutputDirectory" data-scaytid="333">waterMarker.OutputOptions.OutputDirectory</span> = ".";

// Apply watermarks
<span data-scayt_word="waterMarker.Execute" data-scaytid="335">waterMarker.Execute</span>();

// open generated image file in default image viewer installed in Windows
<span data-scayt_word="Process.Start" data-scaytid="337">Process.Start</span>(<span data-scayt_word="outputFilePath" data-scaytid="319">outputFilePath</span>);
}
}
}
  • press F5 to compile and run your first application!

This application source code above takes image file and protects with the visible semitransparent watermark along whole image. With Watermarking SDK you can add multiple watermarks at the same time and batch process images (from files or image objects).

More Samples

For more source code samples explore “ByteScout Samples / Watermarking SDK ” folder in “My Documents”.

Evaluation version adds a reminder text at the bottom of output image files.

You are welcome to purchase a license for the SDK at http://bytescout.com/buy/watermarkingsdk.html

We provide 30-Day Unconditional Money Back Guarantee for the SDK!

Have a Question?

Contact us at support@bytescout.com or use the online contact form at https://bytescout.com/support/index.php?_m=tickets&_a=submit&step=1&departmentid=2

Thanks again for evaluating Watermarking SDK!

[socialpug_share]

Tutorials: