Page 1 of 1

convert to TIFF with JPEG compression, single strip/tile, YBrCR

Posted: 2016-03-07T14:25:44-07:00
by jpunder1@hotmail.com
I am attempting to convert multipage color PDFs to TIFF for import into a document imaging system. The system will only handle the final TIFFs properly if they are stored in one of the following formats:

JPEG - Support only if single strip/tile, and Photometric Interpretation is YCbCr
(OJPEG also supported, but I am ignoring that option for the time being)

These PDF files had been previously converted into color TIFFs using LSW compression, so I can also convert those TIFFS to the JPEG compression format if that is easier.

The biggest problem I have at the moment is figuring out how to create the TIFFs as single strip/tile. I'm not sure if this is even the proper terminology, as I couldn't find anything referencing the option in the forums. I tried setting "-define tiff:rows-per-strip=0", as well as setting it to a very high number such as 300000.

This succeeds in converting an LZW TIFF to JPEG, but white color gets translated to purple (0,128,128), and the strip/tiling is still wrong for our app.
convert Y:\TestMultipage.1.tif -compress jpeg -set colorspace YCbCr Y:\TestMultipage.tif

The following throws an error:
c:\temp\idmhelp>convert Y:\TestMultipage.pdf -compress jpeg -set colorspace YCbCr Y:\TestMultipage.tif
convert.exe: Invalid td_samplesperpixel value. `TIFFVStripSize64' @ error/tiff.c/TIFFErrors/557.
convert.exe: Bogus input colorspace. `JPEGLib' @ error/tiff.c/TIFFErrors/557.

If I remove the colorspace option it is successful, but our app won't take the RGB colorspace that it results in.

What function or parameters should I be looking at for the colorspace and strip/tile settings?

Re: convert to TIFF with JPEG compression, single strip/tile, YBrCR

Posted: 2016-03-07T14:29:53-07:00
by jpunder1@hotmail.com
Sorry, I left out the version and OS info:

Version: ImageMagick 6.9.3-7 Q16 x64 2016-03-06 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib

Os is Windows 7, 64 bit professional with 64 GB of RAM

I will provide some sample files soon.

Re: convert to TIFF with JPEG compression, single strip/tile, YBrCR

Posted: 2016-03-08T08:03:58-07:00
by jpunder1@hotmail.com
Here is the PDF I am trying to convert to TIF.
https://www.dropbox.com/s/qyhvnw1ls219g ... e.pdf?dl=0

This is a TIF that my application will work with, created by scanning the document through the application itself, which uses old style jpeg compression.
https://www.dropbox.com/s/dviyfjpg3c6uw ... t.tif?dl=0

This is what I get when I attempt to convert the PDF to TIF.
https://www.dropbox.com/s/yw9ftlvev2ynk ... t.TIF?dl=0

Re: convert to TIFF with JPEG compression, single strip/tile, YBrCR

Posted: 2016-03-08T08:33:50-07:00
by snibgo
Microsoft Photo Viewer can't display your UsableFormat.tif, complaining about corruption or something.

"identify -verbose UsableFormat.tif" says:

Code: Select all

identify.exe: Depreciated and troublesome old-style JPEG compression mode, please convert to new-style JPEG compression and notify vendor of writing software. 
`OJPEGSetupDecode' @ warning/tiff.c/TIFFWarnings/887.
If this "troublesome old-style JPEG compression mode" is required for your application, I doubt that IM can create it.

Re: convert to TIFF with JPEG compression, single strip/tile, YBrCR

Posted: 2016-03-08T08:49:07-07:00
by GeeMack
jpunder1@hotmail.com wrote:This is what I get when I attempt to convert the PDF to TIF.
https://www.dropbox.com/s/yw9ftlvev2ynk ... t.TIF?dl=0
As snibgo mentioned, your usable TIF seems to be created with an obsolete JPEG compression. One other difference I notice when checking the files is the one that works reports it as 8 bit, and the one that doesn't work reports it as 16 bit. You might try specifying "-depth 8" on your convert command line.

Re: convert to TIFF with JPEG compression, single strip/tile, YBrCR

Posted: 2016-03-08T08:55:29-07:00
by jpunder1@hotmail.com
Thank you for the reply. My application should accept either JPEG or OJPEG formats, according to their developers. The usable image was created by the application, as they still use pretty old code for everything. What I need to get is the same single strip/tile and YCbCr as the usable image, but with current JPEG compression.

Does that make any sense?

Re: convert to TIFF with JPEG compression, single strip/tile, YBrCR

Posted: 2016-03-08T09:14:03-07:00
by snibgo
jpunder1@hotmail.com wrote:-set colorspace YCbCr
This won't do what you want. This declares that the RGB values are really YCbCr. Instead, you should change the values from RGB to YBrCr. To do that: "-colorspace YCbCr".

Re: convert to TIFF with JPEG compression, single strip/tile, YBrCR

Posted: 2016-03-08T09:55:57-07:00
by jpunder1@hotmail.com
Thank you so much for that clarification. So the "-set colorpace" defines the input and "-colorspace" the output. Now I can convert the LZW tifs to JPEG TIFFS with the proper coloring (converting directly from PDF still throws the same error as above).

This works to convert tif to tif:
convert Y:\TestMultipage.1.tif -compress jpeg -colorspace YCbCr -depth 8 Y:\TestMultipage.tif

This errors converting PDF to TIF (I can live with this as the above will work for me, including this just for the sake of completeness)
convert Y:\TestMultipage.pdf -compress jpeg -colorspace YCbCr -depth 8 Y:\TestMultipage.tif
convert.exe: Invalid td_samplesperpixel value. `TIFFVStripSize64' @ error/tiff.c/TIFFErrors/557.
convert.exe: Bogus input colorspace. `JPEGLib' @ error/tiff.c/TIFFErrors/557.

How do I get the output to single strip/tile? Am I even using the correct terminology? This is what the vendor told me I need. I think TIFFINFO reports it as "subfile type" where the usable document shows "Subfile Type: (0 = 0x0)" and the ones I am generating show "Subfile Type: multi-page document (2 = 0x2)"