借助ImageMagick工具, 将tiff图片转化为jpg等常见图片格式


1. 借助ImageMagick工具

下载地址: http://www.imagemagick.org/script/download.php

windows版本:

安装位置指定之后, 默认安装一路到底.

2. 编写java代码

凑成下图的命令行:

代码:

package com.Test.tifTranslateJPG;

public class test {
    public static void tiffToJpg(String tifFilePath, String toFilePath){
        String command = "E:\\ImageMagick-7.0.11-Q16-HDRI\\magick " + tifFilePath + " " + toFilePath;
        System.out.println(command);
        cmd(command);
    }

    public static boolean cmd(String command) {
        boolean flag = false;
        try {
            // 调用系统的cmd
            Runtime.getRuntime().exec(command);
            flag = true;
        } catch (Exception exception) {
            exception.printStackTrace();
        }
        return flag;
    }

    public static void main(String[] args) {
        // E:\ImageMagick-7.0.11-Q16-HDRI\magick D:\test\a.tif D:\test\a.jpg
        tiffToJpg("D:\\test\\a.tif", "D:\\test\\a.jpg");
    }

}

运行代码之后, 该目标文件夹下就会出现.jpg结尾的图片.


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM