package com.qs.mp.common.image;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import net.coobird.thumbnailator.filters.ImageFilter;

/**
 * @author zhongcp
 * @Date 2022/4/16
 */
public class ThumbnailsImgFilter implements ImageFilter {
  @Override
  public BufferedImage apply(BufferedImage img) {
    int w = img.getWidth();
    int h = img.getHeight();
    BufferedImage newImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D graphic = newImage.createGraphics();
    graphic.setColor(Color.white);//背景设置为白色
    graphic.fillRect(0, 0, w, h);
    graphic.drawRenderedImage(img, null);
    graphic.dispose();
    return newImage;
  }
}
