diff --git a/Changelog.md b/Changelog.md
index 5a2cead..6cec920 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -13,6 +13,12 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- ...
+## [3.0.1] - 2025-10-30
+
+### Added
+
+- New method `QrGenerator.writeToImage(String)` that returns a `BufferedImage` for a given payload without touching the file system.
+
## [3.0.0] - 2025-04-04
### Added
diff --git a/pom.xml b/pom.xml
index 0fc9c77..617a731 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
+ * This method takes the configuration collected up to here (by using + * the other methods) and a payload string and creates a {@link BufferedImage} + * containing a QR code. + *
+ * Note that calling this method does not change the configuration. + * So you can keep the instance and generate more QR codes without + * repeating the configuration steps. + * + * @param payload the string to be encoded into a QR code + * @return a {@link BufferedImage} containing the generated QR code + * @throws QrGenerationException thrown in case the computation of the + * QR code goes wrong. + */ + public BufferedImage writeToImage(String payload) + throws QrGenerationException { + try { + return generateImage(payload); + } catch (WriterException e) { + throw new QrGenerationException("Failed to write QR code to Image", e); + } + } + private void writeQrCodeToFile(Path tmpFile, String payload) throws WriterException, IOException { final BufferedImage image = generateImage(payload); diff --git a/src/test/java/com/github/aytchell/qrgen/QrGeneratorTest.java b/src/test/java/com/github/aytchell/qrgen/QrGeneratorTest.java index a493922..6885aa6 100644 --- a/src/test/java/com/github/aytchell/qrgen/QrGeneratorTest.java +++ b/src/test/java/com/github/aytchell/qrgen/QrGeneratorTest.java @@ -139,6 +139,12 @@ void tooBigPayloadsFail(SizeAndLevel sizeAndLevel) throws IOException { } } + @Test + void generatorCanCreateBufferedImage() throws QrGenerationException { + final BufferedImage image = new QrGenerator().writeToImage("https://github.com/aytchell/qrgen"); + assertNotNull(image); + } + void generatePayloadWithLvl(int payloadSize, ErrorCorrectionLevel lvl) throws QrGenerationException, IOException { final QrGenerator gen = new QrGenerator() .withErrorCorrection(lvl);