Skip to content

KevinKeul/java-stickercreator

Repository files navigation

Java Sticker Creator

A command-line interface (CLI) application written in Java that batch-processes the transformation of standard images into sticker-ready formats.

Features

  • Automated Background Removal: Employs an edge-detection flood-fill algorithm that determines the primary background color from the image borders and strips it to transparency based on configurable color variance thresholds.
  • Aspect-Aware Rescaling: Automatically centers and fits the processed object within a fixed square canvas..
  • Multi-Layered Custom Borders: Calculates a Euclidean distance map relative to the object's boundary to apply concentric, multi-colored border strokes around the content.
  • Batch Processing: Scans recursively through directories, sorts files by modification date, preserves relative subdirectory structures, and numbers output assets sequentially.

Technical Specifications

The application uses the following main dependencies and frameworks:

  • Modern Java
  • picocli: Used to manage declarative command-line parsing, options, and help generation.
  • Java AWT / ImageIO: Utilized for precise, per-pixel manipulation, structural image reproduction, and output writing.

Configuration Options

The application accepts several CLI parameters to customize its execution. If a parameter is omitted, defaults optimized for standard sticker generation will be used.

Option Long Option Type Default Value Description
-i --input String data/input Path to the input directory containing source images. This is scanned in a recursive manner.
-o --ouput String data/output Path to the target output directory for processed assets.
-s --size Integer 512 The side length of the output square canvas (in pixels).
-ts --types String jpg,jpeg,png,gif Comma-separated list of applicable file extensions.
-bs --borders String 15=white,2=black Comma-separated distance-to-color mapping for border generation.
-m --maxdifference Integer 10 Maximum absolute RGB variance permitted for a neighbouring pixel to be classified as background.

Execution Examples

Compilation

Ensure picocli is present on your classpath, then compile the Main.java file.

Basic Run

Execute the program using the default settings (processes data/input/ and saves results to data/output/):

java-stickercreator

Advanced Custom Configuration

To process a unique folder, increase the target size, loosen the background threshold, and add custom concentric borders (a wide red border on the outside followed by a tight black stroke on the inside):

java-stickercreator \
  --input "/path/to/photos" \
  --ouput "/path/to/stickers" \
  --size 1024 \
  --maxdifference 25 \
  --borders "20=red,4=black"

Core Algorithm Pipeline

For every matching file discovered in the input sequence, the underlying handleImage engine executes three specific transformations sequentially:

  1. removeBackground: Iterates across the outer bounding pixels to find the dominant color. A queue-driven flood fill then replaces pixels of similar value (determined by absolute RGB difference vs --maxdifference) with an alpha value of 0.
  2. scale: Computes an optimal scaling factor to preserve the original aspect ratio while maximizing the graphic within the boundaries defined by --size. It centralizes and renders the scaled product cleanly onto a new TYPE_INT_ARGB canvas.
  3. addBorder: Traces the edges of non-transparent pixel regions. It calculates Euclidean distances outward from these boundaries, mapping pixels to colors according to your --borders configuration to form structured outlines.

About

A command-line interface (CLI) application written in Java that batch-processes the transformation of standard images into sticker-ready formats.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages