Skip to content

#1784 add random fingerprint generator#1789

Open
asolntsev wants to merge 1 commit intomainfrom
feature/1784-fingerprint
Open

#1784 add random fingerprint generator#1789
asolntsev wants to merge 1 commit intomainfrom
feature/1784-fingerprint

Conversation

@asolntsev
Copy link
Copy Markdown
Collaborator

@asolntsev asolntsev commented Apr 5, 2026

Usage:

  • faker.fingerprint().png()
  • faker.fingerprint().png(300, 200, ARCH)
  • faker.fingerprint().base64()
  • faker.fingerprint().base64(800, 800, LOOP)

This is the first time when I tried to create PR with the help of AI (Claude).
I tuned the code format, added tests etc., but didn't dive deep into the algorithm. ¯¯_(ツ)_/¯¯

@mferretti Don't you want to try this version?

@asolntsev asolntsev linked an issue Apr 5, 2026 that may be closed by this pull request
@asolntsev asolntsev self-assigned this Apr 5, 2026
@what-the-diff
Copy link
Copy Markdown

what-the-diff bot commented Apr 5, 2026

PR Summary

  • Added Access to New Fingerprint Feature
    A new function was added in the existing code which enables access to a new feature related to fingerprints.

  • New Fingerprint Image Generation Capability
    A new class was introduced that allows the creation of synthetic fingerprint images. It includes tools for making PNG images and for creating data URLs.

  • Distinct Fingerprint Patterns Classification
    We introduced a classification that classifies fingerprint patterns into three types: WHORL, LOOP, and ARCH.

  • Customizable Generation of Fingerprint Images
    Functions were constructed to allow the generation of fingerprint images based on user-specified dimensions and pattern types.

  • Testing of New Fingerprint Feature
    We created a new process of testing to ensure that the new fingerprint image generation works as intended, including checks on the properties of the PNG images.

@asolntsev asolntsev added the enhancement New feature or request label Apr 5, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 5, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 97.05882% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.35%. Comparing base (47f4512) to head (2dc65dc).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...java/net/datafaker/providers/base/Fingerprint.java 97.01% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1789      +/-   ##
============================================
+ Coverage     92.28%   92.35%   +0.06%     
- Complexity     3445     3479      +34     
============================================
  Files           339      340       +1     
  Lines          6794     6881      +87     
  Branches        670      678       +8     
============================================
+ Hits           6270     6355      +85     
- Misses          356      361       +5     
+ Partials        168      165       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@asolntsev asolntsev force-pushed the feature/1784-fingerprint branch from 17a7a66 to bfdf826 Compare April 5, 2026 09:48
@asolntsev asolntsev requested review from bodiam and kingthorin April 5, 2026 09:56
@asolntsev asolntsev added this to the 2.6.0 milestone Apr 5, 2026
@kingthorin kingthorin requested a review from Copilot April 5, 2026 11:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Fingerprint base provider to generate synthetic fingerprint images as PNG bytes or base64 PNG data URLs, and wires it into the Faker provider surface and documentation.

Changes:

  • Introduces net.datafaker.providers.base.Fingerprint with png(...) and base64(...) APIs (including pattern selection via PatternType).
  • Registers the provider via BaseProviders#fingerprint() and updates GraalVM native-image reachability metadata.
  • Adds provider documentation entries and a JUnit test suite for basic PNG/base64 validation.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/main/java/net/datafaker/providers/base/Fingerprint.java New provider implementation for generating fingerprint images and encoding as PNG / base64 data URLs
src/main/java/net/datafaker/providers/base/BaseProviders.java Exposes the new provider via fingerprint()
src/main/resources/META-INF/native-image/reachability-metadata.json Adds reachability entries for the new provider and its methods
src/test/java/net/datafaker/providers/base/FingerprintTest.java Adds tests for PNG signature/dimensions and base64 data URL behavior
README.md Adds “Fingerprint” to the provider list
docs/documentation/providers.md Adds the Fingerprint provider to the provider table

Usage:
* `faker.fingerprint().png()`
* `faker.fingerprint().png(300, 200, ARCH)`
* `faker.fingerprint().base64()`
* `faker.fingerprint().base64(800, 800, LOOP)`
@asolntsev asolntsev force-pushed the feature/1784-fingerprint branch from bfdf826 to 2dc65dc Compare April 5, 2026 18:49
@mferretti
Copy link
Copy Markdown

@asolntsev
thanks for taking the time — the noise adjustments are a nice touch. That said, this is essentially the first approach I explored as well, and it hits the same fundamental limitation: with a single singularity point, the output doesn't convincingly resemble a real fingerprint.
The key insight from the research — particularly from the BioLab group at the University of Bologna's SFinGe generator — is that realistic synthetic fingerprints need multiple singularity points (cores and deltas) driving a directional map. The flow of ridges around these points is what produces the characteristic arches, loops, and whorls. A single core gives you something that looks more like a bullseye than a real print.
The reference worth looking at is SFinGe by Cappelli et al. — their four-step pipeline (directional map → density map → ridge pattern → noising) is the gold standard, but most of it can be simplified for our purposes.
Specifically: the density map can be reduced to a constant ridge frequency, the rendering to a simple grayscale threshold plus mild noise. What actually matters is the directional map and the ridge generation — and the latter doesn't need real Gabor convolution. You can compute it analytically per pixel as cos(2π · (x·cosθ + y·sinθ) / λ), where θ(x,y) comes from the directional map and λ is your (constant) ridge wavelength. That's O(width × height), no convolution, fast in Java.
With 2–4 cores/deltas placed randomly within plausible regions you get real fingerprint topology at minimal computational cost — and that's exactly what I'm currently banging my head on 🙂 (given the limited time i have after work+family). Happy to compare notes.

@bodiam
Copy link
Copy Markdown
Contributor

bodiam commented Apr 6, 2026

@mferrettmate are you using AI to write your messages? If so, could you please not do that? Thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

simulate fingerprint images

5 participants