package org.xmx0632.deliciousfruit.service;
import java.awt.Color;
import java.awt.Font;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.xmx0632.deliciousfruit.global.ConfigConstant;
import org.xmx0632.deliciousfruit.utilities.image.WaterMarkUtil;
@Component
public class WaterMarkService {
private static Logger log = LoggerFactory.getLogger(WaterMarkService.class);
public static String MARK_FONT_NAME = Font.SANS_SERIF;
public static int MARK_FONT_SIZE = 18;
public static Color MARK_FONT_COLOR = Color.RED;
public static int MARK_FONT_STYLE = Font.TRUETYPE_FONT;
public static int LENGTH_TO_RIGHT = 26;
public static int LENGTH_TO_BOTTOM = 16;
public static String CONTEXT_REALPATH = "";
@Autowired
private ConfigService configService;
public void printWaterMark(String inputFileName, String outputFileName) {
String markText = configService.getByName(ConfigConstant.WATER_MARK);
String markPic = CONTEXT_REALPATH
+ configService.getByName(ConfigConstant.WATER_MARK_LOGO);
log.debug("Water mark text:" + markText);
log.debug("Water mark logo file:" + markPic);
log.debug("Water mark output file:" + outputFileName);
WaterMarkUtil.pressTextAndImage(markText, markPic, inputFileName,
outputFileName, MARK_FONT_NAME, MARK_FONT_STYLE,
MARK_FONT_COLOR, MARK_FONT_SIZE, LENGTH_TO_RIGHT,
LENGTH_TO_BOTTOM);
}
}