Hi,
I am using Aspose Total product in my project and I am facing issues while converting TIFF images with multiple pages into a PDF doc.
Here is the code, I am using.
TiffImage multiImage = (TiffImage) com.aspose.imaging.Image.load( << Image File Path>>);
int frameCounter = 0;
for (TiffFrame tiffFrame : multiImage.getFrames() )
{
multiImage.setActiveFrame(tiffFrame);
Color[] pixels = multiImage.loadPixels(tiffFrame.getBounds());
JpegOptions jpgCreateOptions = new JpegOptions();
jpgCreateOptions.setSource(new FileCreateSource(<>, false));
JpegImage jpgImage = (JpegImage)com.aspose.imaging.Image.create(jpgCreateOptions,tiffFrame.getWidth(),tiffFrame.getHeight());
{
jpgImage.savePixels(tiffFrame.getBounds(), pixels);
jpgImage.save();
Pdf pdf1 = new Pdf();
Section sec1 = pdf1.getSections().add();
aspose.pdf.Image img1 = new aspose.pdf.Image(sec1);
sec1.getParagraphs().add(img1);
img1.getImageInfo().setFile(<>);
pdf1.save(<<PDF_filename>>);
jpgImage.dispose();
}
While trying to load at this line,
“TiffImage multiImage = (TiffImage) com.aspose.imaging.Image.load”, the program hangs for some time and after that throws an exception as below,
com.aspose.imaging.exceptions.FrameworkException: Cannot allocate so many bytes. Use LoadPartialPixels instead.
at com.aspose.imaging.RasterImage$b.process(Unknown Source)
at com.aspose.imaging.RasterImage$c.process(Unknown Source)
at com.aspose.imaging.RasterImage$c.process(Unknown Source)
at com.aspose.imaging.internal.ch.t$a.a(Unknown Source)
at com.aspose.imaging.internal.bs.s.a(Unknown Source)
at com.aspose.imaging.internal.bs.s.a(Unknown Source)
at com.aspose.imaging.internal.ch.t.a(Unknown Source)
at com.aspose.imaging.internal.ch.ag.loadPixels(Unknown Source)
at com.aspose.imaging.RasterCachedImage.loadPixelsInternal(Unknown Source)
at com.aspose.imaging.RasterImage.a(Unknown Source)
at com.aspose.imaging.RasterImage.a(Unknown Source)
at com.aspose.imaging.RasterImage.loadPartialPixels(Unknown Source)
at com.aspose.imaging.fileformats.tiff.TiffImage.loadPixelsInternal(Unknown Source)
at com.aspose.imaging.RasterImage.a(Unknown Source)
at com.aspose.imaging.RasterImage.a(Unknown Source)
at com.aspose.imaging.RasterImage.loadPixels(Unknown Source)
Is this a known issue? I was searching in the forum and came to know that there was indeed an issue with multipage tiff images for Aspose Java.
Please help. This issue is blocking further processing as well.
P.S. - If anyone needs the TIFF image, I am trying to convert, please give me your email ID. I’ll send it to you.
Thanks,
Wasim
Hi,
Just noticed that my application now is not even throwing an exception. It simply remains hanging at this line. :((
"TiffImage multiImage = (TiffImage) com.aspose.imaging.Image.load( << Image File Path>>);"
Thanks,
Wasim
Hi Wasim,
- Operating system version
- Operating system architecture
- JDK type
- JDK version
Hi,
Thanks for replying.
I have sent the image to your mail as instructed. My system details are :
OS version: windows server 2008 R2 standard
OS Arch: 64 bit machine
JDK type: 64 bit
JDK version: 7 update 60
Attached are the details.
Please let me know if you need any more info.
Thanks,
Wasim
Hi Wasim,
Hi Babar,
How to check the Aspose Imaging version? We have Aspose.Total for Java license.
20160623
3.0
Does it help?
Thanks,
Wasim
Hi Wasim,
System.out.println(com.aspose.imaging.BuildVersionInfo.ASSEMBLY_VERSION);
It is aspose-imaging-2.1.0.0-jdk16
Hi Wasim,
Ok, will check and let you know.
Could you please also inform how to get the latest updates for licensed Aspose products. Do we have to download the jars and use?
-Thanks
Hi,
I tried with aspose-imaging-2.6.0-jdk16.jar as you suggested but it threw the same exception,
Tiff convert error. Saving as blank page :TESTCOPY.TIF
class com.aspose.imaging.exceptions.FrameworkException: Cannot allocate so many bytes. Use LoadPartialPixels instead.
com.aspose.imaging.RasterImage$e.process(Unknown Source)
com.aspose.imaging.RasterImage$f.process(Unknown Source)
com.aspose.imaging.RasterImage$f.process(Unknown Source)
com.aspose.imaging.internal.cs.a$a$h.a(Unknown Source)
com.aspose.imaging.internal.bm.I.a(Unknown Source)
com.aspose.imaging.internal.bm.I.a(Unknown Source)
com.aspose.imaging.internal.cs.a$a.a(Unknown Source)
com.aspose.imaging.internal.bm.I.a(Unknown Source)
com.aspose.imaging.internal.bm.I.a(Unknown Source)
com.aspose.imaging.internal.cs.a.a(Unknown Source)
com.aspose.imaging.internal.cp.d.loadPartialPixels(Unknown Source)
com.aspose.imaging.RasterImage$b.a(Unknown Source)
com.aspose.imaging.internal.bm.I.a(Unknown Source)
com.aspose.imaging.internal.bm.I.a(Unknown Source)
com.aspose.imaging.RasterImage.loadPixelsInternal(Unknown Source)
com.aspose.imaging.RasterImage.a(Unknown Source)
com.aspose.imaging.RasterImage.a(Unknown Source)
com.aspose.imaging.RasterImage.loadPartialPixels(Unknown Source)
com.aspose.imaging.fileformats.tiff.TiffImage$a.loadPartialPixels(Unknown Source)
com.aspose.imaging.RasterImage$b.a(Unknown Source)
com.aspose.imaging.internal.bm.I.a(Unknown Source)
com.aspose.imaging.internal.bm.I.a(Unknown Source)
com.aspose.imaging.RasterImage.loadPixelsInternal(Unknown Source)
com.aspose.imaging.RasterImage.a(Unknown Source)
com.aspose.imaging.RasterImage.a(Unknown Source)
com.aspose.imaging.RasterImage.loadPixels(Unknown Source)
sg.apl.q2c.asposejava.ScanNewEmail.processAttachment(ScanNewEmail.java:489)
sg.apl.q2c.asposejava.ScanNewEmail.processEmailFolder(ScanNewEmail.java:285)
sg.apl.q2c.asposejava.ScanNewEmail.run(ScanNewEmail.java:89)
java.lang.Thread.run(Unknown Source)
at com.aspose.imaging.RasterImage$e.process(Unknown Source)
at com.aspose.imaging.RasterImage$f.process(Unknown Source)
at com.aspose.imaging.RasterImage$f.process(Unknown Source)
at com.aspose.imaging.internal.cs.a$a$h.a(Unknown Source)
at com.aspose.imaging.internal.bm.I.a(Unknown Source)
at com.aspose.imaging.internal.bm.I.a(Unknown Source)
at com.aspose.imaging.internal.cs.a$a.a(Unknown Source)
at com.aspose.imaging.internal.bm.I.a(Unknown Source)
at com.aspose.imaging.internal.bm.I.a(Unknown Source)
at com.aspose.imaging.internal.cs.a.a(Unknown Source)
at com.aspose.imaging.internal.cp.d.loadPartialPixels(Unknown Source)
at com.aspose.imaging.RasterImage$b.a(Unknown Source)
at com.aspose.imaging.internal.bm.I.a(Unknown Source)
at com.aspose.imaging.internal.bm.I.a(Unknown Source)
at com.aspose.imaging.RasterImage.loadPixelsInternal(Unknown Source)
at com.aspose.imaging.RasterImage.a(Unknown Source)
at com.aspose.imaging.RasterImage.a(Unknown Source)
at com.aspose.imaging.RasterImage.loadPartialPixels(Unknown Source)
at com.aspose.imaging.fileformats.tiff.TiffImage$a.loadPartialPixels(Unknown Source)
at com.aspose.imaging.RasterImage$b.a(Unknown Source)
at com.aspose.imaging.internal.bm.I.a(Unknown Source)
at com.aspose.imaging.internal.bm.I.a(Unknown Source)
at com.aspose.imaging.RasterImage.loadPixelsInternal(Unknown Source)
at com.aspose.imaging.RasterImage.a(Unknown Source)
at com.aspose.imaging.RasterImage.a(Unknown Source)
at com.aspose.imaging.RasterImage.loadPixels(Unknown Source)
Please look into it.
Thanks,
Wasim
Itsak26:Ok, will check and let you know.
Could you please also inform how to get the latest updates for licensed Aspose products. Do we have to download the jars and use?
Hi Babar,
Thanks for the info.
Yes, please look into case as soon as possible. The thing is if the application throws Exception, it can be handled but the biggest issue is sometimes the program hangs there and all further processing gets blocked and application needs restart. Can you suggest a work-around for the same for the time being from the code I sent to you?
Thanks,
Wasim
Hi Wasim,
Cache.setCacheFolder(temporaryFolderLocation);
Hi Wasim,
Hi Babar,
I checked my application and these are my JVM settings during startup. So, I think the memory should be fine.
REM JVM configuration
set PR_JVMMS=256
set PR_JVMMX=1024
set PR_JVMSS=4000
Thanks,
Wasim
+919874636222
Hi Wasim,
Hi Babar,
Okay, will do that. Meanwhile I was testing with another Image file and I got this exception.
com.aspose.imaging.exceptions.ImageLoadException: Image loading failed.
at com.aspose.imaging.Image.a(Unknown Source)
at com.aspose.imaging.Image.load(Unknown Source)
at sg.apl.q2c.asposejava.ScanNewEmail.processAttachment(ScanNewEmail.java:495)
at sg.apl.q2c.asposejava.ScanNewEmail.processEmailFolder(ScanNewEmail.java:294)
at sg.apl.q2c.asposejava.ScanNewEmail.run(ScanNewEmail.java:89)
at java.lang.Thread.run(Unknown Source)
Caused by: class com.aspose.imaging.internal.Exceptions.SystemException: com.aspose.imaging.exceptions.ImageLoadException: Unable to read file. Exception:Error loading file: Unsupported file format
Parameter name: input —> com.aspose.imaging.exceptions.ImageLoadException: Unable to read file. Exception:Error loading file: Unsupported file format
Parameter name: input
Why the aspose is throwing unsupported file exception with the attached TIF file? Could you please check.
Thanks,
Wasim
Hi Wasim,
Hi Babar,
Regarding your earlier suggestion about gradual increase of Java heap size, I created one sample application and observed the same issue of “com.aspose.imaging.exceptions.FrameworkException: Cannot allocate so many bytes. Use LoadPartialPixels instead”. at 128m memory.
I increased the JVM heap size from 128m till 1024m gradually but the exception didnt go. My system didnt allow me to go further than 1024m.
Is there any other way to load a large pixel image in Aspose imaging API list?
Thanks,
Wasim