ImageMagick use on Windows

Source: Internet
Author: User
Tags imagemagick

1. New and old version difference

The old version of ImageMagick, using the convert.exe.
The new version is using Magick.exe.

The difference is that when used, the command is different.

convert -quality 75%   D:/1.jpg  E:/1.jpgmagick -quality 75%   D:/1.jpg  E:/1.jpg

Without doing more testing, what I'm actually using now is:
The new version is now 7.0.7 http://www.imagemagick.org/script/download.php
The old version is 6.2.7 Https://pan.baidu.com/s/1gfpPo1X

2.Why???

Because the Windows system has the same command, convert. The estimate was based on the consideration that ImageMagick converted convert to magick.

3. Why use the old version

It is now not successful to call ImageMagick directly using Java in the form of a call to CMD. The reason was not found.

String command = "cmd /c magick -quality 75% E:/1.jpg E:/2.jpg"; Process p = null;  Runtime run = Runtime.getRuntime();  try {      p = run.exec(command);      System.out.println(command);    p.waitFor();      in = p.getInputStream();      BufferedReader read = new BufferedReader(new InputStreamReader(in));      String result = read.readLine();      System.out.println("INFO:"+result); } catch (Exception e) {      e.printStackTrace();  }  

Moreover, the previous Im4java used in Linux to call ImageMagick, Im4java,,, does not support the new version. Im4java older, should be in ImageMagick before the new version is not updated, so Im4java and the new version of ImageMagick incompatible.
So, choose to use the old version.

Use of 4.im4java

Introducing Dependencies

<dependency>    <groupId>org.im4java</groupId>    <artifactId>im4java</artifactId>    <version>1.4.0</version></dependency>

Java Methods for compressing pictures

long zoomstart,zoomend;zoomstart = System.currentTimeMillis();start = System.currentTimeMillis();IMOperation operation = new IMOperation();operation.addImage(orgfileName);operation.quality(0.1);operation.addImage(zoomfileName);ConvertCmd cmd = new ConvertCmd();cmd.setSearchPath("C:\\Program Files (x86)\\ImageMagick-6.2.7-Q16");  //Windows需要设置,Linux不需要cmd.run(operation);zoomend = System.currentTimeMillis();  System.out.println("生成压缩图片时间 start time:" + zoomstart+ "; end time:" + zoomend+ "; Run Time:" + (zoomend - zoomstart) + "(ms)");

ImageMagick use on Windows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.