将每个tiff帧转换为jpeg格式,并使用java将其转换为pdf格式

author author     2022-12-27     639

关键词:

This technical tip shows how each TIFF frame can be converted to JPEG and then these images to PDF file using Aspose.Pdf for Java. Aspose.Pdf for Java is very well capable of dealing with TIFF images and can easily transform them into PDF format. However there are cases when a TIFF image contains frames with different resolution or page orientation and product might not work well. So in order to resolve such issues, we can first convert TIFF frames into individual JPEG images and then save these images into PDF format using Aspose.Pdf for Java.
  1. // read the source TIFF image
  2. ImageInputStreamiis = ImageIO.createImageInputStream(new FileInputStream("d:/pdftest/BW_MultiPage_TIFF.tif"));
  3. Iterator<ImageReader> readers = ImageIO.getImageReaders(iis);
  4. // create ImageReader object to parse the Image
  5. ImageReaderir = readers.next();
  6. // specify the input source
  7. ir.setInput(iis);
  8. // get the count of frames in TIFF image
  9. intframeCount = ir.getNumImages(true);
  10. // iterate through each TIFF frame
  11. for (int i = 0; i <frameCount; ++i)
  12. // save the individual TIFF frame as separate image with JPEG compression
  13. ImageIO.write(ir.read(i), "jpg", new File("d:/pdftest/TIFF_JPEG_Coversion/frame" + i + ".jpg"));
  14. // show the total count of tiff frames (optional)
  15. // System.out.println("Tiff contains: "+frameCount+" frames");
  16.  
  17.  
  18. // specify the directory containing JPEG images
  19. String image_Directory = "d:/pdftest/TIFF_JPEG_Coversion/";
  20. // read the files from Image directory
  21. File f = new File(image_Directory);
  22. // get the list of files in directory
  23. File[] fa = f.listFiles();
  24.  
  25. //Instantiate a Pdf object by calling its empty constructor
  26. Pdf pdf1 = new Pdf();
  27. //Create a section in the Pdf object
  28. Section sec1 = pdf1.getSections().add();
  29.  
  30. for (int i = 0; i <fa.length; i++)
  31. {
  32. // by default each image will be added as new paragraph on new page
  33. //Create an image object in the section
  34. aspose.pdf.Image img1 = new aspose.pdf.Image(sec1);
  35. //Add image object into the Paragraphs collection of the section
  36. sec1.getParagraphs().add(img1);
  37. //Set the path of image file
  38. img1.getImageInfo().setFile(fa[i].getPath());
  39. //Set the image file Type
  40. img1.getImageInfo().setImageFileType(ImageFileType.Jpeg);
  41. }
  42. //Save the Pdf
  43. pdf1.save("d:/pdftest/JPEG_image_toPDF.pdf");
  44. // close InputStream holding TIFF image
  45. iis.close();

在python中将tiff转换为jpeg

】在python中将tiff转换为jpeg【英文标题】:convertingtifftojpeginpython【发布时间】:2015-03-0505:14:54【问题描述】:谁能帮我阅读.tiff图像并转换成jpeg格式?fromPILimportImageim=Image.open(\'test.tiff\')im.save(\'test.jpeg\')上面的代码不工作。【问... 查看详情

java示例代码_在java中将TIFF转换为JPEG/PNG

java示例代码_在java中将TIFF转换为JPEG/PNG 查看详情

如何使用 Ghostscript 将 DOCX 或 DOC 文件转换为 TIFF 格式?

】如何使用Ghostscript将DOCX或DOC文件转换为TIFF格式?【英文标题】:HowcanIconvertDOCXorDOCfiletoTIFFformatusingGhostscript?【发布时间】:2015-04-1305:32:36【问题描述】:有什么方法可以在PHP中将DOCX或DOC文件转换为TIFF格式?【问题讨论】:你... 查看详情

delphi:怎么把jpeg、bmp,wmf等timage支持的格式转化为tiff?

...件呢?请高手指点。我问的是编程处理。//利用GDI将图片转换为tif格式//使用前先下载GDIPlus//以下代码GDIPlus+delphi7通过//转换后的图片与原图片在同一目录下varimg1:TGPImage;ImgGUID:TGUID;beginopendialog1.Filter:='支持的所有图片格式|*.png;*... 查看详情

gdal:pythongdal.translate可以将tiff文件转换为jpeg或png数组-而不是写入文件吗?(代码片段)

我有python代码将GeoTIFF图像文件转换为JPEG图像文件。但是,我想在内存中执行此操作,这意味着我想读取GeoTIFF文件,将其转换为JPEG,然后将转换后的数据存储到内存结构中,就像理想情况下的numpy数组一样。有没有办法做到这一... 查看详情

Ghostscript 将 PDF 转换为大的 TIFF

】Ghostscript将PDF转换为大的TIFF【英文标题】:GhostscriptconvertPDFintolargeTIFF【发布时间】:2015-06-2609:21:19【问题描述】:我想使用Ghostscript将PDF调整为TIFF格式。我们使用长度或高度限制为5米的PDF/X-3作为输入。因此,我想要tiff-尺寸... 查看详情

以编程方式为 Silverlight 显示选择图像转换格式为 JPEG 或 PNG

】以编程方式为Silverlight显示选择图像转换格式为JPEG或PNG【英文标题】:ProgrammaticallychoosingimageconversionformattoJPEGorPNGforSilverlightdisplay【发布时间】:2011-02-1821:53:27【问题描述】:我有一个项目,我需要将大量图像类型转换为可在S... 查看详情

abbyyfinereaderpdf15如何将页面保存为图像

...仅能将文档页面保存为图像,而且还提供了多种图像保存格式,满足不同的文档页面使用需求。接下来,一起来具体了解下这项功能吧。一、另存为页面图像功能如图2所示,ABBYYFineReaderPDF15提供了丰富的另存为选项,可将PDF页面... 查看详情

使用imazing软件将heic格式的图片转换为常见格式,例如jpeg,png

...接下来,小编就来教大家使用iMazing软件将HEIC格式的图片转换为常见格式,例如JPEG,PNG。图1:HEIC格式一、HEIC格式介绍HEIC格式文件好处在于不损失画质的情况下,相比JPEG格式能够大大的减少文件所占用的空间,节省手机储存空... 查看详情

在 OpenCV 中不使用 CvSaveImage 将 IplImage 转换为 JPEG

】在OpenCV中不使用CvSaveImage将IplImage转换为JPEG【英文标题】:ConvertIplImageintoaJPEGwithoutusingCvSaveImageinOpenCV【发布时间】:2010-10-1609:59:53【问题描述】:我希望将IplImage转换为内存中的JPEG图像(以便将其作为M-JPEG帧通过套接字传输)... 查看详情

将大量 MP3 文件转换为 YouTube 视频,每个都使用相同的 JPEG 图像

】将大量MP3文件转换为YouTube视频,每个都使用相同的JPEG图像【英文标题】:ConvertingalargenumberofMP3filestovideosforYouTube,eachusingsametheJPEGimage【发布时间】:2020-06-0122:51:24【问题描述】:我正在寻找一种将大量MP3文件转换为视频的方法... 查看详情

将不同的图片格式(jpg、gif、png等)转换为TIFF格式

】将不同的图片格式(jpg、gif、png等)转换为TIFF格式【英文标题】:Convertdifferentpictureformats(jpg,gif,png,etc.)toTIFFformat【发布时间】:2012-08-0706:32:41【问题描述】:我正在通过OCR从图像中读取文本。它只支持TIFF格式的图像。所以,... 查看详情

在 .NET 2.0 中将位图转换为一个多页 TIFF 图像

】在.NET2.0中将位图转换为一个多页TIFF图像【英文标题】:ConvertbitmapstoonemultipageTIFFimagein.NET2.0【发布时间】:2008-12-2919:19:56【问题描述】:如何将位图数组转换为全新的TIFF格式图像,并将所有位图作为帧添加到这个新的tiff图像... 查看详情

使用java将透明的gif / png转换为jpeg

】使用java将透明的gif/png转换为jpeg【英文标题】:Convertingtransparentgif/pngtojpegusingjava【发布时间】:2010-10-0215:56:55【问题描述】:我想使用Java将gif图像转换为jpeg。它适用于大多数图像,但我有一个简单的透明gif图像:Inputgifimageht... 查看详情

使用 scala 将 JavapairRDD 转换为数据帧

】使用scala将JavapairRDD转换为数据帧【英文标题】:transformJavapairRDDtodataframeusingscala【发布时间】:2020-02-2422:26:09【问题描述】:我有一个以下格式的javapairRDDorg.apache.spark.api.java.JavaPairRDD[com.vividsolutions.jts.geom.Geometry,com.vividsolutions. 查看详情

OpenOffice 和 MS Office 格式转换为 TIFF

】OpenOffice和MSOffice格式转换为TIFF【英文标题】:OpenOfficeandMSOfficeformatsconversionintoTIFF【发布时间】:2011-05-1113:56:24【问题描述】:我正在寻找一组.NET组件(或转换解决方案),它们允许将源文档转换为一系列光栅图像(多页TIFF... 查看详情

将 YV12 (yuv420p) 转换为 JPEG / Bitamp

】将YV12(yuv420p)转换为JPEG/Bitamp【英文标题】:ConvertYV12(yuv420p)toJPEG/Bitamp【发布时间】:2017-08-0409:42:31【问题描述】:在onPreviewFrame使用android.hardware.Camera,如果我使用默认的NV21格式,我可以使用YuvImage压缩成jpeg格式,效果很好。... 查看详情

帮助使用 JPEG 压缩更改 TIFF 文件中的 DPI

】帮助使用JPEG压缩更改TIFF文件中的DPI【英文标题】:HelpchangingDPIinaTIFFfilewithJPEGcompression【发布时间】:2011-03-0115:34:49【问题描述】:我有一个来自扫描仪的Tiff文件。它的分辨率为300dpi。但稍后我需要将其更改为不同的值,例如... 查看详情