@Override public String getContent() { if (hasBeenCalledBefore) { return txt.toString(); } else { hasBeenCalledBefore = true; } // Placeholders: internalFileName, fileName, binary, width and height String[] arr = path.split("/"); String fileName = arr[arr.length - 1]; String internalFileName = System.currentTimeMillis() + fileName; // String binary = ImageUtils.getImageHexaBase64(path); String imageformat = path.substring(path.lastIndexOf('.') + 1); String binary = ImageUtils.getImageHexaBase64(bufferedImage, imageformat); setUpSize(); String res = img_template; res = res.replace("{fileName}", fileName); res = res.replace("{internalFileName}", internalFileName); res = res.replace("{binary}", binary); res = res.replace("{width}", width); res = res.replace("{height}", height); txt.append(res); return txt.toString(); }
@Override public String getContent() { if (hasBeenCalledBefore) { return txt.toString(); } else { hasBeenCalledBefore = true; } // Placeholders: internalFileName, fileName, binary, width and height String[] arr = path.split("/"); String fileName = arr[arr.length - 1]; String internalFileName = System.currentTimeMillis() + fileName; // String binary = ImageUtils.getImageHexaBase64(path); String imageformat = path.substring(path.lastIndexOf('.') + 1); String binary = ImageUtils.getImageHexaBase64(bufferedImage, imageformat); setUpSize(); String res = img_template; res = res.replace("{fileName}", fileName); res = res.replace("{internalFileName}", internalFileName); res = res.replace("{binary}", binary); res = res.replace("{width}", width); res = res.replace("{height}", height); txt.append(res); return txt.toString(); }
@Test public void sanityTestLocal() throws IOException{ ImageUtils imageUtils = new ImageUtils(); assertNotNull(imageUtils); BufferedImage bufferedImage = ImageIO.read(new File(Utils.getAppRoot() + "/src/test/resources/dtpick.gif")); String hexa = ImageUtils.getImageHexaBase64(bufferedImage, "gif"); assertEquals(1, TestUtils.regexCount(hexa, "R0lGODlhEAAQAPMAAKVNSkpNpUpNSqWmpdbT1v")); }