你如何使用im4java调整图像大小? [英] How do you resize an image using im4java?

查看:494
本文介绍了你如何使用im4java调整图像大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用im4java调整图像大小。我没有找到任何工作示例,他们的JavaDocs也不完整。

I'm trying to resize an image using im4java. I haven't found any working examples and their JavaDocs are incomplete.

OOTB Java解决方案不足,导致生成的图像质量很差,尽管渲染提示调整。

OOTB Java solutions are insufficient and lead to poor quality in the resulting images, despite rendering hint adjustments.

推荐答案

首先,im4java是imagemagick和/或graphicsmagick的接口,所以你需要在你的计算机上安装其中一个让im4java工作。

First of all, im4java is an interface for imagemagick and/or graphicsmagick, so you need to install one of them on your computer to get im4java to work.

以下是调整图片大小的代码:

Here is the code to resize an image:

ConvertCmd cmd = new ConvertCmd();

IMOperation op = new IMOperation();
op.addImage("original_image.jpg");
op.resize(800,600);
op.addImage("resized_image.jpg");

cmd.run(op);

这篇关于你如何使用im4java调整图像大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆