Nis*_*ant 23
使用JMagick(docs).阅读文档.它提供了ImageMagick的所有功能.您还可以查看另一个ImageMagick Java包装器im4java.
有一个很好的启动文档im4java 这里
这是一个例子,我已经解决了.
/** Typical scaling implementation using JMagick **/
ImageInfo origInfo = new ImageInfo(absPath); //load image info
MagickImage image = new MagickImage(origInfo); //load image
image = image.scaleImage(finalWidth, finalHeight); //to Scale image
image.setFileName(absNewFilePath); //give new location
image.writeImage(origInfo); //save
Run Code Online (Sandbox Code Playgroud)
编辑#1:
如果你想知道JMagick的Jar文件.下载jMagick tarball,解压它.
$ tar xvzf jmagick-linux-6.4.0-Q32.tar.gz
./jmagick-6.4.0.jar
./jmagick.jar
./libJMagick-6.4.0.so
./libJMagick.so
Run Code Online (Sandbox Code Playgroud)
小智 9
如何在Windows上安装JMajick
对于 ImageMagic 1.4.0
// create command
ConvertCmd cmd = new ConvertCmd();
// create the operation, add images and operators/options
IMOperation op = new IMOperation();
op.addImage("source_picture.jpg"); // source file
op.resize(800,600);
// of op.resize(800); // and height calculate automatically
op.addImage("resized_picture.jpg"); // destination file file
// execute the operation
cmd.run(op);
Run Code Online (Sandbox Code Playgroud)
如果你喜欢maven!
<dependency>
<groupId>org.im4java</groupId>
<artifactId>im4java</artifactId>
<version>1.4.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
42914 次 |
| 最近记录: |