I'm writing code that runs on Google App Engine (Java). What I'm trying to do is augment an existing image by adding text. GAE does not have any text handling in its ImagesService. Does anyone have any idea?
I'd like my code to look something like this:
...
// Read image
byte[] pageData = readImage("images/page.png");
Image pageImage = ImagesServiceFactory.makeImage(pageData);
// Add text here
...
return pageImage;
Creating an App Engine application is easy, and only takes a few minutes. And it's free to start: upload your app and share it with users right away, at no charge and with no commitment required. Google App Engine applications can be written in the Java, Python, Go or PHP programming languages. This tutorial covers Java.
Google App Engine applications can be written in the Java, Python, Go or PHP programming languages. This tutorial covers Java. If you would prefer to use Python, Go or PHP to build your applications, see the Python, Go or PHP guides. Use Apache Maven to easily create an App Engine project with required layout and files.
The following are the steps to convert an image having a single line of text. Create an object of the AsposeOcr class. Convert image to text using AsposeOcr.recognizeLine (String fullPath) method.
In a browser running on the same machine as your terminal window, visit localhost:8080 to access the app. If you aren't already signed-in, click Sign in, supply an email, and click Log In. Supply a text message in the textbox and click Post Greeting. Observe that the greeting is now displayed in the greetings list under your email name.
If you just need to overlay some simple text you could combine the Google Charts API with the Composite image function in the AppEngine Image API to get the desired result.
First construct a URL and use urlfetch from your app to grab the required text-image via the Charts API like:
URL: http://chart.apis.google.com/chart?chs=300x50&cht=p3&chtt=hello&chts=FFFFFF,24&chf=bg,s,000000 (Note the size, and colour params in this url)
Open your image with the Image API and use Composite with the image you wish to overlay text on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With