Skip to content

Instantly share code, notes, and snippets.

@nazt
Created April 3, 2010 08:46
Show Gist options
  • Save nazt/354277 to your computer and use it in GitHub Desktop.
Save nazt/354277 to your computer and use it in GitHub Desktop.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import watermarker.exception.WatermarkerException;
import watermarker.impl.DefaultWatermarker;
import watermarker.model.WatermarkerSettings;
/**
*
* @author NAzT
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws MalformedURLException, FileNotFoundException, WatermarkerException {
// 1st param to Watermarker#watermark(...)
URL imageUrl = new URL("file:///Users/NAzT/Desktop/blackra1n1.jpg");
// 2nd param to Watermarker#watermark(...)
String watermarkText = "Hello World";
// 3rd param to Watermarker#watermark(...)
File outputImageFile = new File("/Users/NAzT/Desktop/blackra1n1_watermark.jpg");
OutputStream outputStream = new FileOutputStream(outputImageFile);
// 4th param to Watermarker#watermark(...)
WatermarkerSettings watermarkerSettings = WatermarkerSettings.DEFAULT;
// 4.5th set position of watermarks
watermarkerSettings.getWatermarkSettings().setY( 0.1f );
watermarkerSettings.getWatermarkSettings().setX( 0.75f );
// Actual call to Watermarker#watermark(...)
new DefaultWatermarker().watermark(imageUrl, watermarkText, outputStream, watermarkerSettings);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment