
Thread
2015.06.13 05:51 "Re: [Tiff] [PATCH] Fix multi-page fax scaling", by Lee Howard
I've committed the patches as suggested except for part #3 which you state is not universally-suitable. If you want that part addressed please crease a universal solution.
Please check-out and test current CVS to make-sure that you are happy with the commit.
Thanks,
Lee.
On 05/21/2014 03:05 AM, Eduardo Robles Elvira wrote:
> Hello everybody,
>
> Hey I'm new to the list =) I'm Eduardo from Wadobo, a small software > development company from Spain. In request from a client, we have
> created the following patch that we want to adapt as needed (and if > possible) to contribute it upstream:
>
> Basically we use libtiff to process fax tiff images. Some fax machines > send multiple pages as one very long page. The trick here is to split
> the page at the correct A4 page boundary and keep the correct aspect > ratio of the image.
>
> We have a set of example files and a script to process them as a test > case. Ideally, the output of the "test_pdf.sh" script should be the same
> as the input tiff images but in pdf. The test case can be downloaded > from here [1].
>
> I've created two patches, that you can find attached to this email: > libtiffcrop-fix.patch and libtiff-correct-fax-scaling.patch:
>
> 1. libtiffcrop-fix.patch fixes a small problem in tiffcrop, it seems it > was incorrectly using TIFFSetField instead of CopyField.
>
> And in libtiff-correct-fax-scaling.patch we have some other changes:
>
> 2. I had to remove a check in main() that didn't allow maxPageWidth to > be bigger than pageWidth.
> 3. in get_subimage_count() I had to comment some lines that were trying > to calculate how many pages a subimage would need, because it really
> needed only one in our test case. This might need some improvement (any > ideas?). This is the part of the patch:
>
> - if (pagewidth)
> - *ximages = (int)ceil((scale * imagewidth) /
> (pagewidth - overlap)); /* Max horz pages needed */
> - else
> +// if (pagewidth)
> +// *ximages = (int)ceil((scale * imagewidth) /
> (pagewidth - overlap)); /* Max horz pages needed */
> +// else
>
>
> 4. the pagewidth variable was being set as the maxpagewidth instead, > which made all the calculations bad. This made sense when the check in
> point 2 was in place, but not anymore. I've modified it so that > pagewidth is set with the specified pagewidth when maxpagewidth is
> bigger. This part of the patch:
>
> - *view_height = maxPageHeight * PS_UNIT_SIZE;
> + if (pgheight != 0 && pgheight < maxPageHeight)
> + *view_height = pgheight * PS_UNIT_SIZE;
> + else
> + *view_height = maxPageHeight * PS_UNIT_SIZE;
>
> 5.
>
> * The remaining lines of the patch - in exportMaskedImage() -
> basically fix the scaling.
>
> Any and all constructive feedback that can help us get the patch in
> libtiff is welcome.
>
> Thanks for your time,
> --
> [1] http://wadobo.com/static/test_fax_pdf.tar.bz2