社区
Java SE
帖子详情
怎么用java把tiff格式的图片转jpg的图片
navyxin
2004-08-04 12:52:44
如题
...全文
734
3
打赏
收藏
怎么用java把tiff格式的图片转jpg的图片
如题
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
netsea_wangchao
2004-12-07
打赏
举报
回复
兄弟
java读取不了tif图片
dreamno
2004-08-16
打赏
举报
回复
为了说明图像I/O库的用法,下面的例子使用JFileChooser提示输入图像文件名。选中文件后再选择目标输出格式,然后按下“Save(保存)”按钮。保存完成后,将重新读取图像并在一个新窗口内显示。
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;
import java.io.*;
import java.net.*;
import javax.imageio.*;
public class Converting extends JFrame { JLabel promptLabel; JTextField prompt; JButton promptButton; JFileChooser fileChooser; JComboBox comboBox;? JButton saveButton;? public Converting() { super("Image Conversion"); setDefaultCloseOperation(EXIT_ON_CLOSE); Container contentPane = getContentPane(); JPanel inputPanel = new JPanel(); promptLabel = new JLabel("Filename:"); inputPanel.add(promptLabel); prompt = new JTextField(20); inputPanel.add(prompt); promptButton = new JButton("Browse"); inputPanel.add(promptButton); contentPane.add(inputPanel, BorderLayout.NORTH);
fileChooser = new JFileChooser(); promptButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { int returnValue = fileChooser.showOpenDialog(null); if (returnValue == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); if (selectedFile != null) { prompt.setText(selectedFile.getAbsolutePath()); } } } } );
JPanel outputPanel = new JPanel(); String writerFormats[] = ImageIO.getWriterFormatNames(); ComboBoxModel comboBoxModel = new DefaultComboBoxModel(writerFormats); comboBox = new JComboBox(comboBoxModel); outputPanel.add(comboBox); saveButton = new JButton("Save"); outputPanel.add(saveButton); saveButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { String name = prompt.getText(); File file = new File(name); if (file.exists()) { BufferedImage image = ImageIO.read(file.toURL()); if (image == null) { System.err.println("Invalid input file format"); } else { String selection = (String)comboBox.getSelectedItem(); String outputFilename = name + "." + selection; File outputFile = new File(outputFilename); boolean found = ImageIO.write(image, selection, outputFile); if (found) { JDialog window = new JDialog(); Container windowContent = window.getContentPane(); BufferedImage newImage = ImageIO.read(outputFile); JLabel label = new JLabel(new ImageIcon(newImage)); JScrollPane pane = new JScrollPane(label); windowContent.add(pane, BorderLayout.CENTER); window.setSize(300, 300); window.show(); } else { System.err.println("Error saving"); } } } else { System.err.println("Bad filename"); } } catch (MalformedURLException mur) { System.err.println("Bad filename"); } catch (IOException ioe) { System.err.println("Error reading file"); } } } );
contentPane.add(outputPanel, BorderLayout.SOUTH);
} public static void main(String args[]) { JFrame frame = new Converting(); frame.pack(); frame.show(); }}
dreamyes
2004-08-10
打赏
举报
回复
FCXIsPig FCX=new FCXIsPig(250);
FCX.pig(FCX);
then
System.out.println("FCX is real 250,is 24k pig");
java
实现
JPG
图像文件
转
换
TIFF
文件 有源码。有工程
(
Java
实现)
JPG
to
TIFF
等
图片
格式
和
TIFF
图片
合并功能解决方案。 有需要的看一看
tiff
转
换
jpg
java
亲测过了
tiff
转
换
jpg
jai_codec-1.1.3.jar jai_core-1.1.3.jar
PDF
转
换
图片
JPG
2
可以把pdf文件
转
换成
jpg
, gif,bmp,
tiff
,png 的
图片
格式
. 可以把
jpg
, gif,bmp,
tiff
,png 的
图片
格式
转
换成pdf文件. pdf to
jpg
的主要特性: 1.把pdf文件
转
换成
jpg
、bmp、
tiff
、gif、png等等
图片
格式
. 2.把
jpg
、bmp、...
多页tif生成多个单页
jpg
图片
多页tif生成多个单页
jpg
图片
的byte[],然后
转
为多个具体
图片
,内容包含工具类及测试类Demo,jai_core-1.1.3.jar,jai-codec-1.1.3.jar。
利用GDAL把TIF文件
转
换为bmp,png等
格式
图片
并对
图片
进行压缩
资源声明:部分资源来自于互联网 代码利用GDAL
转
TIF文件为png、bmp等
格式
图片
并根据屏幕分辨率对
图片
进行压缩。解决了因tif文件过大造成内存溢出等问题,欢迎相互学习
Java SE
62,614
社区成员
307,326
社区内容
发帖
与我相关
我的任务
Java SE
Java 2 Standard Edition
复制链接
扫一扫
分享
社区描述
Java 2 Standard Edition
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章