Add copyright logo on top photo using java
1 /* 2 * To change this template, choose Tools | Templates 3 * and open the template in the editor. 4 */ 5 6 7 /** 8 * Author:: UniqueDevelopers.blogspot.in 9 */ 10 11 12 import java.awt.Graphics2D; 13 import java.awt.image.BufferedImage; 14 import java.io.File; 15 import javax.imageio.ImageIO; 16 17 public class ImageCopyright { 18 19 public static void main(String ar[]) { 20 File actual = new File("input.png"); 21 22 try { 23 24 BufferedImage img1 = ImageIO.read(new File("copyright.png")); 25 if (actual.isFile() && actual.getName().contains(".png") || actual.getName().contains(".PNG") || actual.getName().contains(".jpg") 26 || actual.getName().contains(".JPG") 27 || actual.getName().contains(".JPEG") 28 || actual.getName().contains(".jpeg")) { 29 BufferedImage img = ImageIO.read(new File(actual.getAbsolutePath())); 30 Graphics2D g = img.createGraphics(); 31 int width = (int) Math.round(0.80 * img.getWidth()); 32 int height = (int) Math.round(0.80 * img.getHeight()); 33 if ((int) Math.round(0.20 * img.getWidth()) >= 95 34 && (int) Math.round(0.80 * img.getHeight()) >= 107) { 35 g.drawImage(img1, width, height, 95, 107, null); 36 } else { 37 g.drawImage(img1, width, height, img1.getWidth() / 15, img1.getHeight() / 15, null); 38 } 39 g.dispose(); 40 File outputfile = new File("output.jpg"); 41 ImageIO.write(img, "jpg", outputfile); 42 System.out.println("Image Copyright Successfull......"); 43 } 44 } catch (Exception e) { 45 e.printStackTrace(); 46 System.out.println("Invalid Image Found"); 47 } 48 } 49 }-->

Reviews And Feedback is welcome.
ReplyDelete