Shinama has asked for the wisdom of the Perl Monks concerning the following question:

I greet you wise Monks,

once more (it's been quite some time :D) I ask you for help.
My problem is the following: A few years ago someone in my company created .spl-(PCL) Files to archive some sort of bills. I now have the task of transforming the zipped .spls back into a .pdf

I'm stuck at the point where it comes to transforming the .spl files into a pdf. The problem is that the spl apparently has two pages (page1: layout page2: data) instead of one (layout + data).

My first idea was "hey that's similar to what you can do with layers in Gimp!" so I wanted to do just that (with perl)
I created two seperate tiffs with ghostscript but I found no way of mergin the two tiffs into one (similar to what happens if you use layers in Gimp or Photoshop).

Is something like this possible? I tried Image::Magick but it just makes one file but doesn't use the Layer-like thingy I want =(
If you have a hint that could help me, please tell me :)

Thanks in advance for your time,
Shinama

P.S. my english sucks, sorry for that ;(
EDIT SAYS: The problem has kinda been "resolved": I was unlucky enough to get some wrong tiffs/pcl-files... the big majority is apparently correct. It was decided that a combination/merging of the files isn't needed and because of that the problem solved itself :P I will try your tips & advices for myself as soon as I have the time for that. Thanks to everyvone who tried to help me :)
---------------------------------------------------
"You read too much and understand too little."
Moiraine Damodred (The Wheel of Time)

Replies are listed 'Best First'.
Re: Merging Tiff Files
by dpetrov (Acolyte) on Jun 30, 2009 at 09:27 UTC
    Hello, Why dont you use command line instead?
    Packages: netpbm - Graphics conversion tools libtiff-tools - TIFF manipulation and conversion tools

    and after that....

    tiffcp - combines one or more files created according to the Tag I +mage File Format, Revision 6.0 into a single TIFF file. Because the +output file may be compressed using a different algorithm than the in +put files, tiffcp is most often used to convert between different com +pression schemes.

    and after that...

    tiff2pdf opens a TIFF image and writes a PDF document to standard +output.
      Hello dpetrov,

      thanks for your hints.
      I'm working under Win32 and all the sources I found are for Linux/Unix distributions (except Cygwin).
      Is there a way of using them under windows (without Cygwin)? In the "worst"case scenario I will use my Linux PC but since Windows is the main OS at the company, I would prefer Windows.
      I'm curious if "your" tools can acomplish what I described in the answer to Martin's post.

      Thanks for your help,
      Shinama
      ---------------------------------------------------
      "You read too much and understand too little."
      Moiraine Damodred (The Wheel of Time)
Re: Merging Tiff Files
by mscharrer (Hermit) on Jun 30, 2009 at 09:01 UTC
    Hi, You want to overlay the tiff files is it? The one is the background the other the foreground layer? Imagemagick is the right tool. There is also a command line program called 'convert' which can be used. You do not need a Perl script for this as long you do not need to do more than just the image manipulation. Google gives you the following link when you search for "image magick overlay". The command described there should do the trick.

    http://www.randomsequence.com/articles/overlaying-images-with-imagemagick/

    If you need to do it with Perl/Image::Magick than I'm sure that this package gives you all the options the command line tool gives you. Just check the manual how to do it exactly.

    Best, Martin

      Hello Martin,

      thanks for the advice. I tried it but the effect is not exactly what I need: The sources are black/white tiffs. Because of the nature of blending one picture into another, both pictures black & white parts look kinda bad :(

      Someone told me that with the LeadTools (funny name <_<) it would be possible to do some kind of mathematic: you (apparently) can tell the tools: take both pictures, and if a pixel is black in one of the pictures, make the target pixel in the output file black too. That's similiar to blending but it should save the black/white parts of the tiff.

      Is something like that possible with Perl::Magick? I tried the XOR functions, the different combining functions etc but still I'm not able do to that.

      Perhaps it's not possible to do what I would need but if there is a chance please tell me. And even if I fail I learned something about manipulating images with perl so it wasn't for nothing :D

      Thanks for your help in advance,
      Shinama
      ---------------------------------------------------
      "You read too much and understand too little."
      Moiraine Damodred (The Wheel of Time)
        Hi,

        sorry I don't have a in-deep knowledge of image magick. I just use it from time to time and then I just check the online manual. But it should be possible with it.

        The XOR function is not what you need, more like an OR function. Just check the manual again and google for it.

        Martin

Re: Merging Tiff Files
by poolpi (Hermit) on Jun 30, 2009 at 11:03 UTC

    See GhostPCL

    # Convert the pcl file mypcl.pcl to PDF # with output written to mypcl.pdf. pcl6 -sDEVICE=pdfwrite -sOutputFile=mypcl.pdf mypcl.pcl


    hth,
    PooLpi

    'Ebry haffa hoe hab im tik a bush'. Jamaican proverb
      Hello PooLpi,

      thats something I'm already able to do, the problem is that the PCL-source has two pages that should be one (one page = layout, second = data) :(
      I splitted the pcl in two seperate tiff's with Ghostscript in order to combine them later on. But that's way more difficult that I thought.

      Greetings,
      Shinama
      ---------------------------------------------------
      "You read too much and understand too little."
      Moiraine Damodred (The Wheel of Time)
Re: Merging Tiff Files
by dk (Chaplain) on Jul 01, 2009 at 13:01 UTC
    I apologize I don't know how layers work in Gimp or Photoshop, so correct me if I wrong. Do I understand correctly that you need to combine two images with text, black on white, so that the text from both pages gets combined, while the extensions of the page stays the same? If so, then you need to combine them using binary "and" operator. I'm sure that ImageMagick can do that trick, I just was never curious about how exactly, but I can give you code that works with Prima, and you can try it and tell if it does the right thing:
    use Prima; my $a = Prima::Image-> load('a.tif'); my $b = Prima::Image-> load('b.tif'); $a-> put_image(0,0,$b,rop::AndPut); $a-> save('c.tif');