2014.10.15 04:10 "[Tiff] tiff2pdf page ordering", by Richard Nolde

2014.10.15 14:32 "Re: [Tiff] tiff2pdf page ordering", by Olivier Paquet

2014-10-15 0:10 GMT-04:00 Richard Nolde <richard.nolde@centurylink.net>:

Given what you are writing into the PAGENUMBER tag, the qsort must be reordering the output.

That makes sense and would explain the difference between platforms. tiff2pdf could be more robust and use a stable sort or some other means of not reordering the pages if they have the same number. It already has some (buggy looking) code to detect swapped page numbers and total page count. I don't have a windows build setup around to test it but I believe this fix to t2p_cmp_t2p_page would do the trick:

Index: tools/tiff2pdf.c

=================================================================== RCS file: /cvs/maptools/cvsroot/libtiff/tools/tiff2pdf.c,v retrieving revision 1.73

diff -r1.73 tiff2pdf.c
1200c1200,1201
< * by page number.
---

>  * by page number. If the page numbers are the same, we fall back to comparing
>  * directory numbers to preserve the order of the input file.

1205c1206,1211
< return( ((T2P_PAGE*)e1)->page_number - ((T2P_PAGE*)e2)->page_number );
---

>       int d;
>       d = (int32)(((T2P_PAGE*)e1)->page_number) - (int32)(((T2P_PAGE*)e2)->page_number);
>       if(d == 0){
>               d = (int32)(((T2P_PAGE*)e1)->page_directory) - (int32)(((T2P_PAGE*)e2)->page_directory);
>       }
>       return d;

If someone could test this on windows, I'd happily check it in.

Olivier