Here is the processing process:
Start---> Resolve the IMG image address from the Web page---> download to the local--> zoom processing picture---> Plus watermark effect
-----> Upload to FTP---> storage complete give feedback----> end
Here is the code implementation:
Online picture address: String Sourcefilepath = "Http://m2.img.libdd.com/farm5/2012/0914/11/BB0C1C675286CF6D30A23F5C96EB07FDA
5d0fe05049e_314_460.jpeg ";
Assemble an HTML code fragment String Destimgpath = Parseimgutils.testuseex (Sourcefilepath);
filename String filename = "e:\\ftppath\\hello.jpg";
Download to local try {urlconnectiondownloader.download (destimgpath, filename);
catch (Exception e) {e.printstacktrace ();
///By the specified length, Width scale picture size jpgtransformer Jpgtransformer = new Jpgtransformer ();
String filename2 = "E:\\ftppath\\hello_new.jpg";
try {//NOTE: The real upload is the scaled file Jpgtransformer.transform2 (filename, filename2, 500, 400);
catch (Exception E1) {e1.printstacktrace ();
//Add watermark effect in this markpicture.presstext ("Software of CAs", filename2, "Song Body", 1, 1, 25, 5, 5);
Delay 1 seconds to perform the following operation try {thread.currentthread ();
Thread.Sleep (1000);
catch (Interruptedexception e) {e.printstacktrace (); //Upload to FTP address
Ftpupload ftpupload = new Ftpupload ("* * *", "* * *", "* * *");
File File = new file (filename2);
String destfilename = File.getname ();
String FileName = s.substring (LastIndexOf ("\"), fullfilename.length);
String fileString2 = filename.substring (Filename.lastindexof ("\") + 1, filename.length ());
Through time generation random file name destFileName = randomfilename.createfilenamebydate () + ". jpg";
destFileName = Randomfilename.uuidfilename ();
Input stream definition InputStream in = null;
try {in = new FileInputStream (file);
catch (FileNotFoundException ex) {ex.printstacktrace ();
//Set up the uploaded FTP catalogue String ftppath = "Download";
Set filename and directory if (Ftpupload.upmyfile (destFileName, in, ftppath) = = True) {System.out.println ("Picture file uploaded to FTP server succeeded!"); Set feedback/File upload successful, remember the uploaded file with the previous original data is linked to String Destfilepath = Ftpupload.getftpfilepath (Ftppath, Destfilen
AME); Sourefilepath with the Destfilepath, with the algorithm, I'm just doing a simple relationship here.(with the MAP key value), the following can be used in the data library, file storage mode, the way map<string, string> relatemap = new treemap<string, string> ();
Relatemap.put (Sourcefilepath, Destfilepath);
ImageUrl URL =new ImageUrl ();
Url.setdestfilepath (Destfilepath);
Url.setsourcefilepath (Sourcefilepath);
Add a code, the world's only Url.setflag (destFileName);
Storing data in a database dbconn db = new Dbconn ();
Db.savetodb (URL);
}else{System.out.println ("Picture file uploaded to FTP server failed, please try again or the Department administrator!");
}
Other operations-related APIs are also used, but you can write yourself and view the blogs you've written before.