TIFF to PDF conversion

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
rperez

TIFF to PDF conversion

Post by rperez »

Hi All,
I have a C++ application running on Linux.
I need to convert TIFF data to PDF. I also need it to be in-memory process without reading/writing to/from files.
is there any way I could do it with ImageMagick?

Thanks,
Ronen.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

The ImageMagick Magick++ interface has blob methods for importing and exporting images in memory.
rperez

Re: TIFF to PDF conversion

Post by rperez »

Hi there,
I tried to run this sample code:

const string& fFileName = "c:\\1RegPage.tiff";
Image image(fFileName);

Blob blob;
image.magick( "PDF" );
image.write( &blob );
Image image2(blob);
try
{
image2.write("c:\\1RegPage.pdf");
}
catch (Magick::Exception& e)
{
cout << "EXCEPTION!!! - " << e.what() << endl;
}
and the output was:

EXCEPTION!!! - ImageMagick: NegativeOrZeroImageSize `c:\1RegPage.pdf' `c:\1RegPage.pdf'

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

what am I doing wrong? is TIFF to PDF supported that way?

Thanks,
Ronen.
rperez

Re: TIFF to PDF conversion

Post by rperez »

Hi,
I forgot to mention that I am working with ImagaMagick 6.2.8-8.

Ronen.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: TIFF to PDF conversion

Post by magick »

We tried your code with ImageMagick 6.3.2-4, the latest release and it worked without complaint.
rperez

Re: TIFF to PDF conversion

Post by rperez »

Hi There,
I upgraded my version to:
ImageMagick 6.3.2 02/15/07 Q8 http://www.imagemagick.org.

I retried the code I posted.
this time it passed, but there are some problems:
1) The resulting PDF is in much lower quality then when running the convert utility on the same file.
2) The resulting PDF is in much larger (both file size and page size) then when running the convert utility on the same file.
3) both convert and my code takes up to 10 seconds to convert a regular 1 page tiff. in the previous version (6.2.8) it took about 290 MSecs.
what am I doing wrong?

Thanks,
Ronen.
rperez

Re: TIFF to PDF conversion

Post by rperez »

Hi All,
anyone has any idea about why in library version 6.3.2 conversion of TIFF to PDF has poor quality and performance?

I'll appreciate any input that could help.
Thanks,

Ronen.
Post Reply