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("IMeta")) properties.put(meta := new Meta); var cm = img.getColorModel(); ret new BufferedImage(cm, img.getRaster(), cm.hasAlpha() && cm.isAlphaPremultiplied(), properties); }