Skip to content

Commit

Permalink
Resize plugin banner.
Browse files Browse the repository at this point in the history
  • Loading branch information
EazyFTW committed Oct 2, 2020
1 parent ba1d23a commit 5f56e99
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/me/TechsCode/TechDiscordBot/util/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,17 @@ public String getBanner() {
public File getBannerAsFile() {
try {
BufferedImage image = ImageIO.read(new URL(getBanner()));

Image scaled = image.getScaledInstance(960, 540, Image.SCALE_SMOOTH);
BufferedImage bufferedImage = new BufferedImage(960, 540, BufferedImage.TYPE_INT_ARGB);

Graphics2D bGr = bufferedImage.createGraphics();
bGr.drawImage(scaled, 0, 0, null);
bGr.dispose();

File file = new File(getRoleName().toLowerCase() + "_banner.png");

ImageIO.write(image, "png", file);
ImageIO.write(bufferedImage, "png", file);
return file;
} catch (IOException e) {
e.printStackTrace();
Expand Down

0 comments on commit 5f56e99

Please sign in to comment.