Академический Документы
Профессиональный Документы
Культура Документы
PathIterator;
import java.awt.geom.Point2D;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriter;
import javax.imageio.ImageWriteParam;
import javax.imageio.IIOImage;
import java.awt.image.BufferedImage;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.io.IOException;
import java.io.File;
import java.util.Iterator;
import javax.imageio.stream.FileImageOutputStream;
public class waterMark {
public waterMark() {
}
public static void main(String[] args) {
try {
try {
BufferedImage source = ImageIO.read(new File(Filepath));
// this section adjust the height and widht of the image
double height =source.getHeight();
double width =source.getWidth();
double x=0.00000000;
double y=0.00000000;
int widthreturn=0;
int hightreturn=0;
if(width>height){
x=(MaxWidth/width);
height=height*x;
hightreturn=(int)Math.ceil(height);
if(hightreturn>MaxHeight){
y=MaxHeight/height;
width=MaxWidth*y;
widthreturn=(int)Math.ceil(width);
hightreturn=MaxHeight;
}
}else{
y=MaxHeight/height;
width=width*y;
widthreturn=(int)Math.ceil(width);
if(widthreturn>MaxWidth){
x=MaxWidth/width;
height=MaxHeight*x;
hightreturn=(int)Math.ceil(height);
widthreturn=MaxWidth;
}
}
BufferedImage resized =resize(source,
widthreturn,
hightreturn,
RenderingHints.VALUE_INTERPOLATION_BICUBIC,
Logo,logofill,
watermark,
positonx,
positony,
fontSize,
FontColor,
fontfill,
logoPositionx,
logoPositionY,
fontSelect);
writeJPEG(resized,outputPath,quality);
} catch (Exception e) {
e.printStackTrace();
}