convert tiff to pdf

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
iosif aug
Posts: 3
Joined: 2015-11-18T09:07:08-07:00
Authentication code: 1151

convert tiff to pdf

Post by iosif aug »

Hello,

I need to convert a tiff file that has Lab colorspace to a pdf file, and preserve the Lab colorspace to the output pdf.
I used :
convert fileLAB.tiff output.pdf, or
convert fileLAB.tiff -colorspace Lab output.pdf
Also I tried to use folowing code snipet into a C source:
MagickWand* mw;
MagickWandGenesis();
mw = NewMagickWand();
MagickReadImage(mw,"fileLAB.tiff");
MagickSetImageColorspace(mw, LabColorspace );
MagickWriteImage(mw,"output.pdf");
DestroyMagickWand(mw);
MagickWandTerminus();
The problem is that the output.pdf has sRGB colorspace instead of original Lab colorspace.
Does anyone have a solution for preserve Lab colorspace to the putput.pdf ?

Thank you.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert tiff to pdf

Post by snibgo »

Some quick experiments using tiffimages to confirm suggests that IM always converts back to sRGB before writing the PNG.

However, tiff2png seems to preserve the Lab colorspace.
snibgo's IM pages: im.snibgo.com
iosif aug
Posts: 3
Joined: 2015-11-18T09:07:08-07:00
Authentication code: 1151

Re: convert tiff to pdf

Post by iosif aug »

I tried to convert tiff with Lab colorspace to png, using IM convert command.
Seems to be the same problem. The obtained png have sRGB colorspace.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert tiff to pdf

Post by fmw42 »

Did you try

Code: Select all

convert image.tif -set colorspace LAB -colorspace sRGB image.png
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert tiff to pdf

Post by snibgo »

iosif aug wrote:The obtained png have sRGB colorspace.
As far as I know, PNG colour channels are always red, green and blue.
snibgo's IM pages: im.snibgo.com
iosif aug
Posts: 3
Joined: 2015-11-18T09:07:08-07:00
Authentication code: 1151

Re: convert tiff to pdf

Post by iosif aug »

It seems that the problem is converting Lab tiff in PNG.The PNG is always RGB(sRGB).
When is converted a CMYK tiff to pdf, IM converts tiff to PAM image format, and then put this image in pdf file.
In this case(CMYK), the resulting file has same colorspace as the input file .
There is a way in IM to choose image format inside pdf?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert tiff to pdf

Post by fmw42 »

PNG only supports pixel data in RGB channels. It does not support LAB or CMYK channels unless you have a profile to represent the conversion to that channel type.

When you save an image to PDF, it just puts a vector shell about the raster data. I believe the raster data should be in whatever image type you used when you created the PDF. But if you want to extract the raster data from the PDF, you need to use some other tool besides IM to extract it. I think that is pdfimage.
Post Reply