in reply to Downloading images to client PCs

I need to send the purchased document to the client browser ... in multipage TIFF format with group 4 compression ... but what the client sees when they get the image is not at all correct.

Think out of the box on this one. You're selling them bits, and you need to make sure the bits arrive intact. One reliable way to do this, assuming your clients are on Win32, is to send them .zip files. (There's probably an equivalent reliable interchange format for the Mac.)

So, pre-zip your TIFF files on the server side, and serve up .zip files. This will require that your clients have WinZip (or equivalent) installed, but this is a free download from various places. If you have clients with Macs, ask around for what a reliable download format is.

Replies are listed 'Best First'.
Re: Re: Downloading images to client PCs
by QwertyD (Pilgrim) on Sep 12, 2002 at 22:51 UTC

    Aladdin Systems' Stuffit Expander is pretty much the de facto decompression program on the Mac (it's come preinstalled for years). While it has its own compression format, .sit, it can also handle .zip files perfectly (as well as .tar, .gz, .smi, .uu, .lzh, and others). Zip files should pose no problem for Mac users.

    Good idea, dws.


    How do I love -d? Let me count the ways...
Re: Re: Downloading images to client PCs
by MrCromeDome (Deacon) on Sep 12, 2002 at 18:45 UTC
    I like this suggestion. . . pre-zipping the TIFFs is not terribly feasible, but it was pretty easy to whip something up to create them on the fly. Same problem though: when the zip file gets to the client, it's not usable. I was able to open the downloaded zip and look at the contents, but when I tried to view the contents, WinZip reports "Extracting building.jpg; Error: invalid compressed data to inflate." I opened the zip that was created on the fly (the one on the server) to make sure it was valid, and the file seemed ok.

    The code I used looks like this:

    my $file = 'd:\imaging\building.jpg'; my $zip_name = get_session() . ".zip"; my $zip = Archive::Zip->new(); $zip->addFile($file) or die "Can't add to zip!\n"; $zip->writeToFileNamed($zip_name); my $filesize = -s $zip_name; my $buffer; # Read the zip file open READ, "< $zip_name" or die "Cannot open $zip_name for reading: $! +"; binmode READ; { local $/; $buffer = <READ>; } close(READ); binmode STDOUT; print "Content-Disposition: inline; filename=document.zip\n"; print "Content-Length: $filesize\n"; print "Content-Type: application/zip\n\n"; print $buffer;
    I'm serving this up with Apache 2.0.40 on WinXP.

    MrCromeDome

      Same problem though: when the zip file gets to the client, it's not usable.

      Archive::Zip says this:

      Under Windows, things lock up/get damaged

      Q: I'm using Windows. When I try to use Archive::Zip, my machine locks up/makes funny sounds/displays a BSOD/corrupts data. How can I fix this?

      A: First, try the newest version of Compress::Zlib. I know of Windows-related problems prior to v1.14 of that library.

      If that doesn't get rid of the problem, fix your computer or get rid of Windows.