Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing text to Image in Google App Engine (Java)

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;
like image 229
Niv Avatar asked May 16 '11 15:05

Niv


People also ask

How do I create a Google App Engine application?

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.

What programming languages can be used for Google App Engine?

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.

How do I convert an image to text with one line?

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.

How do I send a greeting in the app?

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.


1 Answers

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:

enter image description here

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.

like image 154
Chris Farmiloe Avatar answered Sep 30 '22 10:09

Chris Farmiloe