Macros are supported in text for all presets where text watermarking is used (Simple Text, Annotation and other).

For example you can set watermark text to "This is {{FILENAME}}" and SDK will add watermark text to images like these: "This is image001.jpg", "This is image003.jpg" etc.

Check sample (annotation preset with EXIF macros)

  • {{FULL_PATH}} - full path to the file (including directory and filename)

  • {{FILENAME}} - filename of the picture (including extension, for example: mysample.jpg)

  • {{FILENAME_NO_EXT}} - filename without ext (for example: mysample)

  • {{DIRECTORY}} - directory where picture is stored (for example: c:\my pictures\)

  • {{SIZE}} - file size

  • {{WIDTH}} - picture width (pixels)

  • {{HEIGHT}} - picture height (pixels)

  • {{WIDTH_MM}} - picture width (mm)

  • {{HEIGHT_MM}} - picture height (mm)

  • {{WIDTH_CM}} - picture width (cm)

  • {{HEIGHT_CM}} - picture height (cm)

  • {{WIDTH_INCH}} - picture width (inch)

  • {{HEIGHT_INCH}} - picture height (inch)

  • {{HORZ_RESOLUTION}} - horizontal resolution (DPI)

  • {{VERT_RESOLUTION}} - vertical resolution (DPI)

  • {{LOCAL_TIME}} - picture time using local format (for example: "2:22 PM")

  • {{LOCAL_DATE_SHORT}} - picture short date (for example: "4/17/2006")

  • {{LOCAL_DATE_LONG}} - picture date according to local settings (for example: "Monday, April 17, 2008")

  • {{DATE_YEAR}} - picture date year

  • {{DATE_MONTH}} - picture date month

  • {{DATE_MONTH_2DIGIT}} - picture date month (2 digits, for example: 05)

  • {{DATE_MONTH_NAME_SHORT}} - picture date month short name (for example: Sep)

  • {{DATE_MONTH_NAME_LONG}} - picture date month full name (for example: September)

  • {{DATE_DAY}} - picture date day number

  • {{DATE_DAY_2DIGIT}} - picture date day (2 digits, for example: 09)

  • {{DATE_DAYOFWEEK}} - picture date day of the week

  • {{DATE_HOUR_12}} - picture date hour (12 hours US format)

  • {{DATE_AMPM}} - picture time AM and PM indicator

  • {{DATE_HOUR_24}} - picture date hour (24 hours European format)

  • {{DATE_MINUTE}} - picture time minutes

  • {{DATE_SECOND}} - picture time seconds

  • {{EXIF_ORIGINAL_DATE}} - picture date and time stored in EXIF tags in form of yyyy:MM:dd hh:mm:ss

  • {{EXIF_ORIGINAL_DATE_YEAR}} - picture date year (from EXIF)

  • {{EXIF_ORIGINAL_DATE_MONTH}} - picture date month (from EXIF)

  • {{EXIF_ORIGINAL_DATE_MONTH_2DIGIT}} - picture date month (from EXIF, 2 digits format)

  • {{EXIF_ORIGINAL_DATE_DAY}} - picture date day (from EXIF)

  • {{EXIF_ORIGINAL_DATE_DAY_2DIGIT}} - picture date day (from EXIF, 2 digits format)

  • {{EXIF_ORIGINAL_DATE_MONTH_NAME_SHORT}} - picture date month short name (from EXIF), for example: Sep, Oct

  • {{EXIF_ORIGINAL_DATE_MONTH_NAME_LONG}} - picture date month full name (from EXIF). For example: September, October

  • {{EXIF_ORIGINAL_DATE_DAYOFWEEK}} - picture date day of the week (from EXIF). For example: Monday

  • {{EXIF_ORIGINAL_DATE_HOUR_12}} - picture time hours (from EXIF), 12-hours US format

  • {{EXIF_ORIGINAL_DATE_AMPM}} - picture time AMPM indicator (from EXIF)

  • {{EXIF_ORIGINAL_DATE_HOUR_24}} - picture time European 24-hours format (from EXIF)

  • {{EXIF_ORIGINAL_DATE_MINUTE}} - picture time minutes (from EXIF)

  • {{EXIF_ORIGINAL_DATE_SECOND}} - picture time seconds (from EXIF)

  • {{EXIF_IMAGE_TITLE}} - photo title (if added by or from the camera)

  • {{EXIF_EQUIPMENT_MANUFACTURER}} - camera or other device manufacturer name

  • {{EXIF_EQUIPMENT_MODEL}} - equipment model name

  • {{EXIF_EXPOSURE_TIME}} - exposure time (seconds)

  • {{EXIF_EXPOSURE_PROGRAM}} - exposure program used for the photo. Available values are: Not defined, Manual, Normal program, Aperture priority, Shutter priority, Creative program (biased toward depth of field) Action program (biased toward fast shutter speed) Portrait mode (for closeup photos with the background out of focus) Landscape mode (for landscape photos with the background in focus)

  • {{EXIF_EXPOSURE_BIAS}} - exposure bias

  • {{EXIF_COMPRESSION}} - compression type. This is typacally added by the software (converters etc)

  • {{EXIF_SOFTWARE_USED}} - software title was used to edit the photo

  • {{EXIF_ISO_SPEED}} - ISO speed value (100, 200, 400 etc)

  • {{EXIF_METERING_MODE}} - metering mode. Available values are: unknown, Average, CenterWeightedAverage, Spot, MultiSpot, Pattern, Partial

  • {{EXIF_FLASH}} - flash information. Available values are: Flash did not fire, Flash fired, Strobe return light not detected, Strobe return light detected, Flash fired, compulsory flash mode, Flash fired, compulsory flash mode, return light not detected, Flash fired, compulsory flash mode, return light detected, Flash did not fire, compulsory flash mode, Flash did not fire, auto mode, Flash fired, auto mode, Flash fired, auto mode, return light not detected, Flash fired, auto mode, return light detected, No flash function, Flash fired, red-eye reduction mode, Flash fired, red-eye reduction mode, return light not detected, Flash fired, red-eye reduction mode, return light detected, Flash fired, compulsory flash mode, red-eye reduction mode, Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected, Flash fired, compulsory flash mode, red-eye reduction mode, return light detected, Flash fired, auto mode, red-eye reduction mode, Flash fired, auto mode, return light not detected, red-eye reduction mode, Flash fired, auto mode, return light detected, red-eye reduction mode.

  • {{EXIF_FOCAL_LENGTH}} - focal length (mm)

  • {{EXIF_F_NUMBER}} - F number

  Copy Code
        
using System;
using System.Diagnostics;
using System.Drawing;
using System.Collections.Generic;
using Bytescout.Watermarking;
using Bytescout.Watermarking.Presets;

namespace Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";

            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);

            // Create new watermark
            TextAnnotation preset = new TextAnnotation();

            // Set text with macros displaying information about photo and camera
            // complete list of available macros please see in the SDK documentation 
            preset.Text = @"Date Time: {{LOCAL_DATE_LONG}} {{LOCAL_TIME}} "+
            "\nFilename: {{FILENAME}}\n" +
            "Manufacturer: {{EXIF_EQUIPMENT_MANUFACTURER}}\n" +
            "Model: {{EXIF_EQUIPMENT_MODEL}}\n" +
            "Software: {{EXIF_SOFTWARE_USED}}\n" +
            "Date/Time: {{EXIF_ORIGINAL_DATE}}\n" +
            "Exposure Time: {{EXIF_EXPOSURE_TIME}} sec\n" +
            "Exposure Program: {{EXIF_EXPOSURE_PROGRAM}}\n" +
            "Exposure Bias: {{EXIF_EXPOSURE_BIAS}} EV\n" +
            "F Number: F {{EXIF_F_NUMBER}}\n" +
            "ISO Speed Rating: ISO {{EXIF_ISO_SPEED}}\n" +
            "Flash: {{EXIF_FLASH}}\n" +
            "Focal Length: {{EXIF_FOCAL_LENGTH}} mm\n" +
            "Metering Mode: {{EXIF_METERING_MODE}}";


            // Set watermark font
            preset.Font = new WatermarkFont("Tahoma", FontStyle.Regular, FontSizeType.Percents, 2); // set font size to 2% of the image size

            waterMarker.OutputOptions.OutputDirectory = ".";
            // Add watermark to watermarker
            waterMarker.AddWatermark(preset);

            // Apply watermarks
            waterMarker.Execute();

            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
    }
}