इस कैसे-कैसे उदाहरण में, हम आपको C# का उपयोग करके TIFF में वॉटरमार्क जोड़ने के चरणों के बारे में बताएंगे। कुछ API कॉल करके C# का उपयोग करके TIFF में वॉटरमार्क डालना बहुत आसान है।
सी#का उपयोग करके टिफ वॉटरमार्क डालने के चरण
- Aspose.Imaging for .NET NuGet पैकेज इंस्टॉल करें
- Aspose.Imaging, Aspose.Imaging.ImageOptions और Aspose.Imaging.Brushes नामस्थान शामिल करें
- टिफ़ लोड करने और टिफ़ वॉटरमार्क जोड़ने के लिए Image.Load विधि का उपयोग करें
- वॉटरमार्क के फ़ॉन्ट, रंग और टेक्स्ट के गुणों को सेट करने के लिए Graphics, Font, SolidBrush और StringFormat ऑब्जेक्ट को इंस्टेंट करें।
- Graphics क्लास ऑब्जेक्ट का उपयोग करके Tiff को C# में वॉटरमार्क से सुरक्षित रखें
- टिफ़ वॉटरमार्क के साथ आउटपुट इमेज सेव करें
ऊपर बताए गए चरणों में, हमने इमेज क्लास के लोड मेथड का उपयोग करके पहले टिफ़ इमेज को मेमोरी में लोड किया है। फिर हमने सी # में वॉटरमार्क के साथ टिफ की सुरक्षा के लिए फ़ॉन्ट, ब्रश और टेक्स्ट स्वरूपण के लिए निर्दिष्ट विशेषताओं को निर्दिष्ट किया है। अंत में, हम C# का उपयोग करके Tiff वॉटरमार्क सहेज रहे हैं।
सी # का उपयोग कर टिफ वॉटरमार्क डालने के लिए कोड
using System; | |
using Aspose.Imaging; | |
using Aspose.Imaging.Brushes; | |
using Aspose.Imaging.ImageOptions; | |
namespace AddingTiffWatermark | |
{ | |
class TiffWatermark | |
{ | |
static void Main(string[] args) | |
{ | |
string PathForTiffFile = @"Y:\Downloads\"; | |
//Load the License file | |
License license = new License(); | |
license.SetLicense(PathForTiffFile + "Conholdate.Total.Product.Family.lic"); | |
// Use Image.Load to add tiff watermark using c# in Tiff file | |
using (var image = Aspose.Imaging.Image.Load(PathForTiffFile + "TiffToWatermark.tiff")) | |
{ | |
// Initialize Graphics class instance for loaded Tiff Image | |
Graphics graphics = new Aspose.Imaging.Graphics(image); | |
// Initialize SizeF to store image Size | |
Size size = graphics.Image.Size; | |
// Create an instance of Font to set the font Name, Size and Style | |
Font font = new Aspose.Imaging.Font("Arial", 24, | |
Aspose.Imaging.FontStyle.Bold); | |
// Instantiate SolidBrush and set Color and Opacity | |
SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(); | |
brush.Color = Aspose.Imaging.Color.Red; | |
brush.Opacity = 0; | |
// initialize an object of StringFormat class and | |
// set its various textual properties | |
StringFormat format = new Aspose.Imaging.StringFormat(); | |
format.Alignment = Aspose.Imaging.StringAlignment.Near; | |
format.FormatFlags = Aspose.Imaging.StringFormatFlags.FitBlackBox; | |
// Render the string on image with set font and brush | |
graphics.DrawString("PROTECTED", font, | |
brush, 0, 0, format); | |
// Save protected tiff with watermark in c# | |
image.Save(PathForTiffFile+"WatermarkedTiff.tiff"); | |
} | |
} | |
} | |
} |
उपरोक्त उदाहरण का उपयोग करके, आप अपने .NET प्रोजेक्ट्स में विंडोज डेस्कटॉप, ASP.NET वेब, या कंसोल एप्लिकेशन सहित C# में वॉटरमार्क के साथ Tiff को आसानी से सुरक्षित कर सकते हैं।