@Test public void getImageBaseInfo_tiff() { String imageFilePath = getImageFullPath("20.tiff"); try { Map<String, String> imageBaseInfo = ImageUtil.getImageBasicInfo(imageFilePath); print(imageBaseInfo); org.junit.Assert.assertNotNull(imageBaseInfo); Assert.assertEquals("TIFF", imageBaseInfo.get(ImageUtil.IMAGE_FORMAT)); Assert.assertEquals("0", imageBaseInfo.get(ImageUtil.IMAGE_QUALITY)); Assert.assertEquals("220", imageBaseInfo.get(ImageUtil.IMAGE_WIDTH)); Assert.assertEquals("220", imageBaseInfo.get(ImageUtil.IMAGE_HEIGHT)); } catch (Exception e) { Assert.fail(e.getMessage()); } }
public static Map<String, String> getImageBasicInfo(String imageFilePath) { IMOperation op = new IMOperation(); op.ping(); op.format("%m\n%w\n%h\n%Q"); op.addImage(imageFilePath); try { IdentifyCmd identify = new IdentifyCmd(); ArrayListOutputConsumer output = new ArrayListOutputConsumer(); identify.setOutputConsumer(output); identify.run(op); ArrayList<String> cmdOutput = output.getOutput(); Iterator<String> iter = cmdOutput.iterator(); Map<String, String> map = new Hashtable<String, String>(); map.put(IMAGE_FORMAT, iter.next()); map.put(IMAGE_WIDTH, iter.next()); map.put(IMAGE_HEIGHT, iter.next()); map.put(IMAGE_QUALITY, iter.next()); return map; } catch (Exception ex) { return Collections.emptyMap(); } }
ImageUtil implements ItemImageCons { public static Map<String, String> getImageBasicInfo(String imageFilePath) { IMOperation op = new IMOperation(); op.ping(); op.format("%m\n%w\n%h\n%Q"); op.addImage(imageFilePath); try { IdentifyCmd identify = new IdentifyCmd(); ArrayListOutputConsumer output = new ArrayListOutputConsumer(); identify.setOutputConsumer(output); identify.run(op); ArrayList<String> cmdOutput = output.getOutput(); Iterator<String> iter = cmdOutput.iterator(); Map<String, String> map = new Hashtable<String, String>(); map.put(IMAGE_FORMAT, iter.next()); map.put(IMAGE_WIDTH, iter.next()); map.put(IMAGE_HEIGHT, iter.next()); map.put(IMAGE_QUALITY, iter.next()); return map; } catch (Exception ex) { return Collections.emptyMap(); } } }
ImageUtil implements ItemImageCons { public static Map<String, String> getImageBasicInfo(String imageFilePath) { IMOperation op = new IMOperation(); op.ping(); op.format("%m\n%w\n%h\n%Q"); op.addImage(imageFilePath); try { IdentifyCmd identify = new IdentifyCmd(); ArrayListOutputConsumer output = new ArrayListOutputConsumer(); identify.setOutputConsumer(output); identify.run(op); ArrayList<String> cmdOutput = output.getOutput(); Iterator<String> iter = cmdOutput.iterator(); Map<String, String> map = new Hashtable<String, String>(); map.put(IMAGE_FORMAT, iter.next()); map.put(IMAGE_WIDTH, iter.next()); map.put(IMAGE_HEIGHT, iter.next()); map.put(IMAGE_QUALITY, iter.next()); return map; } catch (Exception ex) { return Collections.emptyMap(); } }  }
ImageUtil implements ItemImageCons { public static Map<String, String> getImageBasicInfo(String imageFilePath) { IMOperation op = new IMOperation(); op.ping(); op.format("%m\n%w\n%h\n%Q"); op.addImage(imageFilePath); try { IdentifyCmd identify = new IdentifyCmd(); ArrayListOutputConsumer output = new ArrayListOutputConsumer(); identify.setOutputConsumer(output); identify.run(op); ArrayList<String> cmdOutput = output.getOutput(); Iterator<String> iter = cmdOutput.iterator(); Map<String, String> map = new Hashtable<String, String>(); map.put(IMAGE_FORMAT, iter.next()); map.put(IMAGE_WIDTH, iter.next()); map.put(IMAGE_HEIGHT, iter.next()); map.put(IMAGE_QUALITY, iter.next()); return map; } catch (Exception ex) { return Collections.emptyMap(); } }  static boolean isDebugMode(); static Info getImageInfo(String imgFile); static String getProperty(Info imageInfo, String propertyName); static Map<String, String> getImageBasicInfo(String imageFilePath); static Map<String, Integer> getImageWH(String imageFilePath); static List<String> splitImage(File srcFile, Double quality, Integer expectedWidth, Integer expectedHeight); static boolean cutAndScaleImage(String sourceFilePath, String destFilePath, Double quality, int xOffset,
                                           int yOffset, int width, int height, int scaleWidth, int scaleHeight); static boolean cutImage(String sourceFilePath, String destFilePath, Double quality, int xOffset,
                                   int yOffset, int width, int height); static boolean scaleImage(BufferedImage sourceImage, int width, int height, String destFilePath,
                                     Double quality); static boolean scaleImage(String sourceFilePath, int width, int height, String destFilePath, Double quality); static String compositImage(String imageSavePath, ImageFormat format, String bgImage, String iconImage,
                                       GravityEnum position, Integer x, Integer y, Integer width, Integer height,
                                       Double rotation); static String compositImage(String imageSavePath, ImageFormat format, String bgImage, String iconImage,
                                       GravityEnum position, Integer x, Integer y, Integer width, Integer height,
                                       Double rotation, boolean deleteIconFile, Double quality); static String drawCircleWithText(String imageSavePath, String text, String textColor, String fontName,
                                            Integer fontSize, String circleFillColor, String circleStrokeColor,
                                            Integer circleStrokeWidth, Integer x, Integer y, Integer w, Double rotation); static String drawRectangleWithText(String imageSavePath, String text, String textColor, String fontName,
                                               Integer fontSize, String rectFillColor, String rectStrokeColor,
                                               Integer rectStrokeWidth, Integer x, Integer y, Integer w, Integer h,
                                               Double rotation); static String createTextImage(String text, boolean autoWrapper, String fontName, Integer fontSize,
                                         String textColor, Double rotation); static String drawRectangle(Integer x, Integer y, Integer w, Integer h, Integer round, String fillColor,
                                       String strokeColor, Integer strokeWidth, Double rotation); static String drawCircle(Integer width, Integer height, String fillColor, String strokeColor,
                                    Integer strokeWidth, Integer x, Integer y, Integer w, Double rotation); static String rotateImage(String originalImagePath, Double rotation); static String _rotateImage(String originalImagePath, Double rotation); static String drawEclipse(String fillColor, String strokeColor, Integer strokeWidth, Integer x, Integer y,
                                     Integer w, Integer h, Double rotation); static String borderImage(String srcImage, int borderWidth, String color); static String drawText(String text, GravityEnum gravity, String fontName, Integer fontSize,
                                  String textColor, String bgColor, Integer width, Integer height, Double rotation); static String autoResize(String srcImagePath); static String autoResize(String srcImagePath, String destImagePath); }
ImageUtil implements ItemImageCons { public static Map<String, String> getImageBasicInfo(String imageFilePath) { IMOperation op = new IMOperation(); op.ping(); op.format("%m\n%w\n%h\n%Q"); op.addImage(imageFilePath); try { IdentifyCmd identify = new IdentifyCmd(); ArrayListOutputConsumer output = new ArrayListOutputConsumer(); identify.setOutputConsumer(output); identify.run(op); ArrayList<String> cmdOutput = output.getOutput(); Iterator<String> iter = cmdOutput.iterator(); Map<String, String> map = new Hashtable<String, String>(); map.put(IMAGE_FORMAT, iter.next()); map.put(IMAGE_WIDTH, iter.next()); map.put(IMAGE_HEIGHT, iter.next()); map.put(IMAGE_QUALITY, iter.next()); return map; } catch (Exception ex) { return Collections.emptyMap(); } }  static boolean isDebugMode(); static Info getImageInfo(String imgFile); static String getProperty(Info imageInfo, String propertyName); static Map<String, String> getImageBasicInfo(String imageFilePath); static Map<String, Integer> getImageWH(String imageFilePath); static List<String> splitImage(File srcFile, Double quality, Integer expectedWidth, Integer expectedHeight); static boolean cutAndScaleImage(String sourceFilePath, String destFilePath, Double quality, int xOffset,
                                           int yOffset, int width, int height, int scaleWidth, int scaleHeight); static boolean cutImage(String sourceFilePath, String destFilePath, Double quality, int xOffset,
                                   int yOffset, int width, int height); static boolean scaleImage(BufferedImage sourceImage, int width, int height, String destFilePath,
                                     Double quality); static boolean scaleImage(String sourceFilePath, int width, int height, String destFilePath, Double quality); static String compositImage(String imageSavePath, ImageFormat format, String bgImage, String iconImage,
                                       GravityEnum position, Integer x, Integer y, Integer width, Integer height,
                                       Double rotation); static String compositImage(String imageSavePath, ImageFormat format, String bgImage, String iconImage,
                                       GravityEnum position, Integer x, Integer y, Integer width, Integer height,
                                       Double rotation, boolean deleteIconFile, Double quality); static String drawCircleWithText(String imageSavePath, String text, String textColor, String fontName,
                                            Integer fontSize, String circleFillColor, String circleStrokeColor,
                                            Integer circleStrokeWidth, Integer x, Integer y, Integer w, Double rotation); static String drawRectangleWithText(String imageSavePath, String text, String textColor, String fontName,
                                               Integer fontSize, String rectFillColor, String rectStrokeColor,
                                               Integer rectStrokeWidth, Integer x, Integer y, Integer w, Integer h,
                                               Double rotation); static String createTextImage(String text, boolean autoWrapper, String fontName, Integer fontSize,
                                         String textColor, Double rotation); static String drawRectangle(Integer x, Integer y, Integer w, Integer h, Integer round, String fillColor,
                                       String strokeColor, Integer strokeWidth, Double rotation); static String drawCircle(Integer width, Integer height, String fillColor, String strokeColor,
                                    Integer strokeWidth, Integer x, Integer y, Integer w, Double rotation); static String rotateImage(String originalImagePath, Double rotation); static String _rotateImage(String originalImagePath, Double rotation); static String drawEclipse(String fillColor, String strokeColor, Integer strokeWidth, Integer x, Integer y,
                                     Integer w, Integer h, Double rotation); static String borderImage(String srcImage, int borderWidth, String color); static String drawText(String text, GravityEnum gravity, String fontName, Integer fontSize,
                                  String textColor, String bgColor, Integer width, Integer height, Double rotation); static String autoResize(String srcImagePath); static String autoResize(String srcImagePath, String destImagePath); static final String IMAGE_QUALITY; static final String IMAGE_HEIGHT; static final String IMAGE_WIDTH; static final String IMAGE_FORMAT; static final boolean isDebug; }