转换为TIFF格式JPG [英] convert tiff to jpg format
本文介绍了转换为TIFF格式JPG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两页TIFF图像。当我将文件转换为JPG格式
我失去了第二页。
是有什么办法可以把TIFF文件两幅图像成一个JPG文件。
,因为TIFF文件是太大了,我必须有什么办法减少TIFF文件大小减少编程的sizes.is?也可能是我的问题。
I have tiff image with two pages. when I convert file to jpg format I lost second pages. Is there any way to put two images on tiff file into one jpg file. Because of tiff files are too big i have to decrease their sizes.is there any way decrease tiff files size programatically ?it could also be solition for my problem
推荐答案
由于TIFF可以包含多个帧,但JPG不能,你需要在每个单个帧转换为JPG。
Since a TIFF can contain multiple frames but JPG can't, you need to convert each single frame into a JPG.
public static string[] ConvertTiffToJpeg(string fileName)
{
using (Image imageFile = Image.FromFile(fileName))
{
FrameDimension frameDimensions = new FrameDimension(
imageFile.FrameDimensionsList[0]);
// Gets the number of pages from the tiff image (if multipage)
int frameNum = imageFile.GetFrameCount(frameDimensions);
string[] jpegPaths = new string[frameNum];
for (int frame = 0; frame < frameNum; frame++)
{
// Selects one frame at a time and save as jpeg.
imageFile.SelectActiveFrame(frameDimensions, frame);
using (Bitmap bmp = new Bitmap(imageFile))
{
jpegPaths[frame] = String.Format("{0}\\{1}{2}.jpg",
Path.GetDirectoryName(fileName),
Path.GetFileNameWithoutExtension(fileName),
frame);
bmp.Save(jpegPaths[frame], ImageFormat.Jpeg);
}
}
return jpegPaths;
}
}
这篇关于转换为TIFF格式JPG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文