first commit

This commit is contained in:
2026-01-14 21:18:15 +01:00
commit fa466d2dfc
5 changed files with 142 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
.kotlin
### IntelliJ IDEA ###
.idea
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
+5
View File
@@ -0,0 +1,5 @@
# librewatmark (work in progress)
Tool to put a watermark on sensitive documents. Useful to mitigate identity theft etc.
Some services for this already exist on the Web, but then you have to trust them. Here the program runs on your machine, offline.
Using the ImageJ library.
+24
View File
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>librewatermark</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>net.imagej</groupId>
<artifactId>ij</artifactId>
<version>1.51h</version>
</dependency>
</dependencies>
</project>
+73
View File
@@ -0,0 +1,73 @@
package org.example;
import ij.IJ;
import ij.ImagePlus;
import ij.process.ImageProcessor;
import java.awt.*;
import java.io.File;
/*
TODO:
- Parse properly the CLI arguments
- Add error handling
- Write many lines with an angle
- Write for any image (format & responsiveness)
- optional: Export to PDF?
*/
public class Main {
public static void main(String[] args) {
if (args.length == 0)
{
System.out.println("Usage: java -jar watermark.jar <input file> -s <string> [-o <output file>]");
System.exit(0);
}
File f = null;
for (int i=0; i<args.length; i++)
{
System.out.println("Argument " + i + ": " + args[i]);
if (i == 0) {
// First argument is input file, if not, gtfo here
String filename = args[i];
f = new File(filename);
if (!f.exists() || f.isDirectory()) {
System.out.println("Input file \"" + filename + "\" does not exist.");
System.exit(1);
}
}
switch(args[i].charAt(0)) {
case '-':
switch (args[i].charAt(1)) {
case 's': // -s string: to be put as watermark
System.out.println("OPTION B");
break;
case 'o': // -o file: output file
System.out.println("OPTION C");
break;
default:
System.out.println("Unknown argument: \"" + args[i] + "\"");
System.exit(1);
break;
}
break;
}
}
// test
ImagePlus image = IJ.openImage(f.getAbsolutePath());
Font font = new Font("Arial", Font.PLAIN, 18);
ImageProcessor ip = image.getProcessor();
ip.setColor(Color.WHITE);
ip.setFont(font);
ip.drawString("Watermark Text", 10, 20);
image.updateAndDraw();
IJ.save(image, "output.png");
}
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB