static BufferedImage cloneBufferedImageWithMeta(BufferedImage img) { if (img == null) null; if (toIMeta(img) != null) ret img; new Hashtable properties; var names = img.getPropertyNames(); if (names != null) for (key : names) properties.put(key, img.getProperty(key)); if (!properties.containsKey("meta")) properties.put(meta := new Meta); var cm = img.getColorModel(); var img2 = new BufferedImage(cm, img.getRaster(), cm.hasAlpha() && cm.isAlphaPremultiplied(), properties); assertNotNull(toIMeta(img2)); ret img2; }