images

images

how to do image watermarking in java? or how to identify watermarked images.. tell something related to the watermarking concept implementation in java?
View Answers

July 22, 2010 at 12:35 PM

Hi Friend,

Try the following code:

import java.io.*;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;
import javax.swing.ImageIcon;
import java.awt.geom.Rectangle2D;

public class ImageWatermarking {
public static void main(String[]args){

try{
File file = new File("C:/rose.jpg");
if (!file.exists()){
System.out.println("File not Found");
}
ImageIcon icon = new ImageIcon(file.getPath());
BufferedImage bufferedImage = new BufferedImage(icon.getIconWidth(),icon.getIconHeight(), BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = (Graphics2D) bufferedImage.getGraphics();
g2d.drawImage(icon.getImage(), 0, 0, null);
AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.5f);
g2d.setComposite(alpha);
g2d.setColor(Color.black);
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setFont(new Font("Arial", Font.BOLD, 30));
String watermark = "Hello World";
FontMetrics fontMetrics = g2d.getFontMetrics();
Rectangle2D rect = fontMetrics.getStringBounds(watermark, g2d);
g2d.drawString(watermark,(icon.getIconWidth() - (int) rect.getWidth()) / 2, (icon.getIconHeight() - (int) rect.getHeight()) / 2);
g2d.dispose();
File fileout=new File("C:/watermarkedImage.jpg");
ImageIO.write(bufferedImage,"jpg", fileout);
}
catch (IOException ioe){}
}
}

Thanks









Related Tutorials/Questions & Answers:
Images in java
Images in java  how to handle images in java
inked images
inked images  How do I eliminate the blue border around linked images
Advertisements
Moving The Images
Moving The Images  How to moving multiple images in one frame using swings
images upload
images upload  I use netbeans IDE 6.8 How i upload any image from any folder to web page
images
jsp images
jsp images  hi I had done a demo application using jsp. And i tried to display some images which is located in the server folder. It has done by using the IP address path of that image folder.. It has been success full in IE
insert images into a Mysql database
insert images into a Mysql database  How can I insert images into a Mysql database
ModuleNotFoundError: No module named 'images'
ModuleNotFoundError: No module named 'images'  Hi, My Python... 'images' How to remove the ModuleNotFoundError: No module named 'images'... to install padas library. You can install images python with following command
HTML background images
HTML background images  How can I specify background images
uiscrollview add images
uiscrollview add images  How to add dynamic images to UIScrollView
Displaying images - JDBC
Displaying images  How to display multiple images on a single jsp from MySql database
Displaying images - JDBC
Displaying images  How to display multiple images on a single jsp from MySql database
background images in css not working
background images in css not working  In the application i'm passing a background image from CSS in the given format ... background-image: url... of adding background images in css
how to space images in html code
how to space images in html code  how to space images in html code
WHAT TYPES OF IMAGES THAT PHP SUPPORTS?
WHAT TYPES OF IMAGES THAT PHP SUPPORTS?  WHAT TYPES OF IMAGES THAT PHP SUPPORTS
Blob images - JSP-Servlet
Blob images  Hi sir how can i retrieve blob images from database using jsp from mysql  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/retrieve-image.shtml Hope that it will be helpful
Adding images in itext pdf
Adding images in itext pdf  Hi, How to add image in pdf file using itext? Thanks   Hi, You can use following code: PdfWriter.getInstance(document,new FileOutputStream("imagesPDF.pdf")); Read more at Inserting
upload images - JSP-Servlet
upload images  How to write the jsp code to upload images into database.   Hi Friend, The link we have provided you will allow you to upload any file therefor it can also upload an image and can insert
need photoes,images - JavaMail
need photoes,images  hi this is nagarjuna. i need james binary server2.3.1 architecture. and i dont know about how it works. i have to give one seminar on mailing technology. so pls send the gif images,and some
regarding images in jsp
regarding images in jsp  Hi, When I am trying to display an image in jsp, i am getting the image of bar charts in webroots/jspchart/web/jspbarchart.jsp.. But actually I am not getting any image in the browser.. Can any one help
java mail sending with images
java mail sending with images  I need to send images through java mail without giving content path(i.e. we don't want hard code the image path)can you tell me the idea?   Please visit the following links: http
how to display multiple images on browser
how to display multiple images on browser  i want to display multiple images on brower including string values from sql database using jsp
how to display multiple images on browser
how to display multiple images on browser  i want to display multiple images on brower including string values from sql database using jsp
ModuleNotFoundError: No module named 'artek-images'
ModuleNotFoundError: No module named 'artek-images'  Hi, My Python... 'artek-images' How to remove the ModuleNotFoundError: No module named 'artek-images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'Flask-Images'
ModuleNotFoundError: No module named 'Flask-Images'  Hi, My Python... 'Flask-Images' How to remove the ModuleNotFoundError: No module named 'Flask-Images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'pinax-images'
ModuleNotFoundError: No module named 'pinax-images'  Hi, My Python... 'pinax-images' How to remove the ModuleNotFoundError: No module named 'pinax-images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'web-images'
ModuleNotFoundError: No module named 'web-images'  Hi, My Python... 'web-images' How to remove the ModuleNotFoundError: No module named 'web-images' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'artek-images'
ModuleNotFoundError: No module named 'artek-images'  Hi, My Python... 'artek-images' How to remove the ModuleNotFoundError: No module named 'artek-images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'eyes-images'
ModuleNotFoundError: No module named 'eyes-images'  Hi, My Python... 'eyes-images' How to remove the ModuleNotFoundError: No module named 'eyes-images' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'frasco-images'
ModuleNotFoundError: No module named 'frasco-images'  Hi, My... 'frasco-images' How to remove the ModuleNotFoundError: No module named 'frasco-images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'images-utils'
ModuleNotFoundError: No module named 'images-utils'  Hi, My Python... 'images-utils' How to remove the ModuleNotFoundError: No module named 'images-utils' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'annotated-images'
ModuleNotFoundError: No module named 'annotated-images'  Hi, My... named 'annotated-images' How to remove the ModuleNotFoundError: No module named 'annotated-images' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'artek-images'
ModuleNotFoundError: No module named 'artek-images'  Hi, My Python... 'artek-images' How to remove the ModuleNotFoundError: No module named 'artek-images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'artek-images'
ModuleNotFoundError: No module named 'artek-images'  Hi, My Python... 'artek-images' How to remove the ModuleNotFoundError: No module named 'artek-images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'compare-images'
ModuleNotFoundError: No module named 'compare-images'  Hi, My... named 'compare-images' How to remove the ModuleNotFoundError: No module named 'compare-images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'compare-images'
ModuleNotFoundError: No module named 'compare-images'  Hi, My... named 'compare-images' How to remove the ModuleNotFoundError: No module named 'compare-images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'dockerbuild-images'
ModuleNotFoundError: No module named 'dockerbuild-images'  Hi, My... named 'dockerbuild-images' How to remove the ModuleNotFoundError: No module named 'dockerbuild-images' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'minchin.pelican.plugins.optimize-images'
ModuleNotFoundError: No module named 'minchin.pelican.plugins.optimize-images...: ModuleNotFoundError: No module named 'minchin.pelican.plugins.optimize-images' How...;minchin.pelican.plugins.optimize-images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'optimize-images'
ModuleNotFoundError: No module named 'optimize-images'  Hi, My... named 'optimize-images' How to remove the ModuleNotFoundError: No module named 'optimize-images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'purge-images'
ModuleNotFoundError: No module named 'purge-images'  Hi, My Python... 'purge-images' How to remove the ModuleNotFoundError: No module named 'purge-images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'Shake-Images'
ModuleNotFoundError: No module named 'Shake-Images'  Hi, My Python... 'Shake-Images' How to remove the ModuleNotFoundError: No module named 'Shake-Images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'sphinxcontrib-images'
ModuleNotFoundError: No module named 'sphinxcontrib-images'  Hi...: No module named 'sphinxcontrib-images' How to remove the ModuleNotFoundError: No module named 'sphinxcontrib-images' error? Thanks   Hi
ModuleNotFoundError: No module named 'sphinxcontrib-images'
ModuleNotFoundError: No module named 'sphinxcontrib-images'  Hi...: No module named 'sphinxcontrib-images' How to remove the ModuleNotFoundError: No module named 'sphinxcontrib-images' error? Thanks   Hi
ModuleNotFoundError: No module named 'tulip-images'
ModuleNotFoundError: No module named 'tulip-images'  Hi, My Python... 'tulip-images' How to remove the ModuleNotFoundError: No module named 'tulip-images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'alice-images'
ModuleNotFoundError: No module named 'alice-images'  Hi, My Python... 'alice-images' How to remove the ModuleNotFoundError: No module named 'alice-images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'annotated-images'
ModuleNotFoundError: No module named 'annotated-images'  Hi, My... named 'annotated-images' How to remove the ModuleNotFoundError: No module named 'annotated-images' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'compare-images'
ModuleNotFoundError: No module named 'compare-images'  Hi, My... named 'compare-images' How to remove the ModuleNotFoundError: No module named 'compare-images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-images'
ModuleNotFoundError: No module named 'django-images'  Hi, My... 'django-images' How to remove the ModuleNotFoundError: No module named 'django-images' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'dockerbuild-images'
ModuleNotFoundError: No module named 'dockerbuild-images'  Hi, My... named 'dockerbuild-images' How to remove the ModuleNotFoundError: No module named 'dockerbuild-images' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'ecosia-images'
ModuleNotFoundError: No module named 'ecosia-images'  Hi, My... 'ecosia-images' How to remove the ModuleNotFoundError: No module named 'ecosia-images' error? Thanks   Hi, In your python

Ads