(Link to the Q/A mentioned: Merging two images) (sorry if any of this sounds a tad weird, it was originally posted under "Answer" as I was unsure of how to handle a question to an answer when I was unable to comment, its fixed now though)
I am using the 1st answer/suggestion that includes the sample bit of code and has over 100 votes/likes/whatever it is on stackoverflow, and everything that references ImageIO throws an IOException. I am quite honestly fairly new to coding, I've been doing it for... 7 years I believe with the first 4 being something called scratch which is a simple block programming language similar to lego mindstorms except it makes a digital program rather than robotic one. Anyway, as of 3 years ago I finally got deeper into java with modding minecraft. I still haven't gotten too far into java :( and am not entirely sure what exceptions are despite trying to look them up.
public void registerIcons(IconRegister iconRegister)
{
File path = new File("mymod:"); // base path of the images
// load source images
BufferedImage core = ImageIO.read(new File(path, "cores/CoreOak.png"));
BufferedImage cap = ImageIO.read(new File(path, "caps/CapGold.png"));
BufferedImage gem = ImageIO.read(new File(path, "overlay2.png"));
// create the new image, canvas size is the max. of both image sizes
int w = Math.max(core.getWidth(), cap.getWidth());
w = Math.max(w, gem.getWidth());
int h = Math.max(core.getHeight(), cap.getHeight());
h = Math.max(h, gem.getHeight());
BufferedImage combined = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
// paint both images, preserving the alpha channels
Graphics g = combined.getGraphics();
g.drawImage(core, 0, 0, null);
g.drawImage(cap, 0, 0, null);
g.drawImage(gem, 0, 0, null);
// Save as new image
ImageIO.write(combined, "PNG", new File(path, "wand/combined.png"));
this.itemIcon = iconRegister.registerIcon(texturePath + "combined");
}
There's the code. The exceptions are under the bufferedImage things, and the ImageIO.write method, they specifically say "Unhandled exception type IOException" I'm not sure if it being minecraft matters, but when I asked in the sense of java in general as this guy did people yelled at me for having it be too broad, so I thought I'd include it.