This README documents the latest release, but master contains the current development version.
This is small pure java library to write text on image. The library aims for real-life usage in production.
It takes care of a text dimensions calculation and central its positioning on an image.
Add the repositories:
repositories {
mavenCentral()
maven { url "http://dl.bintray.com/oembedler/maven" }
}
Dependency:
dependencies {
compile 'com.embedler.moon:jtxt2img:INSERT_LATEST_VERSION_HERE'
}
How to use the latest build with Maven:
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>bintray-oembedler-maven</id>
<name>bintray</name>
<url>http://dl.bintray.com/oembedler/maven</url>
</repository>
Dependency:
<dependency>
<groupId>com.embedler.moon</groupId>
<artifactId>jtxt2img</artifactId>
<version>INSERT_LATEST_VERSION_HERE</version>
</dependency>
The main class JTxt2Img
provides convenient interface to interact with library internals.
/** output file for generated image **/
File file = new File(outputDirectory, "image-0001.jpg");
/** calling builder and generate image with various parameters **/
JTxt2Img.withText(String.valueOf(i))
.backgroundColor("487")
.foregroundColor("278")
.format(ImgTextProperties.IMG_FORMAT.JPG)
.width(50)
.font(Font.getFont(Font.MONOSPACED))
.height(90)
.generate()
.write(file);
Just clone the repo and type
./gradlew build
Running the tests:
./gradlew test
Installing in the local Maven repository:
./gradlew install
The implementation is in Java 7.
The only runtime dependencies are Apache Commons Lang and Slf4j.
License
jtxt2img is licensed under the MIT License. See LICENSE for details.
Copyright (c) 2016, Anton Y
I would appreciate any feedback via Pull Request/Issue.