article by our own esteemed Matt Liotta and another article that showed
a Java command line program that explained drawing text on images using
Java. With this info in hand, I created the following class:
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import java.util.*;
/**
* This class accepts and input file, output file, and text
* to stamp an image with
*/
public class ImageUtils {
//maybe do something later
public void stampImage(String inFile,String outFile,String text) throws
Exception {
// load input image
BufferedImage image = ImageIO.read(new File(inFile));
Graphics graphics = image.getGraphics();
graphics.setFont(new Font("sansserif", Font.PLAIN, 36));
graphics.setColor(Color.black);
graphics.drawString(text, image.getWidth()/2, 46);
// save modified image
String format = "JPG";
ImageIO.write(image, format, new File(outFile));
}
}
I compiled this and placed it in the CLASSES directory in the CF
directory. I then reference the object like so:
<cfobject type="java" class="ImageUtils" name="iu" action=""> <cfset iu.stampImage(infile,outFile,myText)>
<cfset iu="">
So how 'bout that. I learned something new on the Friday before a
holiday!
--
Marlon Moyer, Sr. Internet Developer
American Contractors Insurance Group
phone: 972.687.9445
fax: 972.687.0607
mailto:[EMAIL PROTECTED]
www.acig.com
> -----Original Message-----
> From: George Abraham [mailto:[EMAIL PROTECTED]
> Sent: Friday, May 28, 2004 2:28 PM
> To: CF-Talk
> Subject: Re: Adding a timestamp to images
>
> Try ImageMagick http://www.imagemagick.org/. Really simple and there
is
> also somewhere a CF tag for manipulating it.
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

