This commit is contained in:
nora 2021-05-21 19:22:50 +02:00
parent 2671658b5d
commit 193674d6f0

View file

@ -116,8 +116,8 @@ public class EmoteAddCommand extends Command {
private byte[] resizeImage(byte[] bytes, String format, int size) throws IOException {
reply("Image size too big (" + bytes.length / 1000 + "kB). Resizing image...");
Image image = ImageIO.read(new ByteArrayInputStream(bytes));
int ratio = image.getHeight(null) / image.getWidth(null);
image = image.getScaledInstance(size, size * ratio, Image.SCALE_SMOOTH);
double ratio = (double)image.getHeight(null) / (double)image.getWidth(null);
image = image.getScaledInstance(size, (int) (size * ratio), Image.SCALE_SMOOTH);
ByteArrayOutputStream out = new ByteArrayOutputStream();
BufferedImage bufferedImg = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);