Return-Path: <tiff-bounces@lists.maptools.org>
X-Original-To: info@awaresystems.be
Delivered-To: info@awaresystems.be
Received: from mx-k.b-one.net (mx-k.one.com [91.198.169.58])
	by mail9.b-one.net (Postfix) with ESMTP id 5BC5640080A
	for <info@awaresystems.be>; Wed, 17 Mar 2010 18:08:54 +0100 (CET)
Received: by mx-k.b-one.net (Postfix, from userid 106)
	id 52DA367457CE; Wed, 17 Mar 2010 18:08:54 +0100 (CET)
X-Virus-Scanned: by one.com
X-Spam-Score: 0
X-Spam-Level: 
X-Spam-Status: No, score=0 tagged_above=0 required=4 tests=[none]
X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4
Received: from lists.maptools.org (lists.maptools.org [65.39.174.144]) by
 mx-k.b-one.net (Postfix) with ESMTP id 8227067457DF for
 <info@awaresystems.be>; Wed, 17 Mar 2010 18:08:44 +0100 (CET)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by
 lists.maptools.org (Postfix) with ESMTP id F38621D5C1969; Wed, 17 Mar 2010
 12:07:04 -0500 (EST)
Received: from hermes.med-web.com (unknown [64.186.39.16]) by
 lists.maptools.org (Postfix) with ESMTP id 26D9C1D18DE97 for
 <tiff@lists.maptools.org>; Wed, 17 Mar 2010 11:42:59 -0500 (EST)
Received: from [127.0.0.1] (dhcp232.med-web.com [192.168.240.232]) by
 mail.med-web.com (Postfix) with ESMTP id B35C021C84FF for
 <tiff@lists.maptools.org>; Wed, 17 Mar 2010 12:42:40 -0400 (EDT)
Message-ID: <4BA10680.6020702@pobox.com>
Date: Wed, 17 Mar 2010 12:42:40 -0400
From: Jason Summers <jason1@pobox.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.8)
 Gecko/20100227 Thunderbird/3.0.3
MIME-Version: 1.0
To: tiff@lists.maptools.org
References:
 <30670617.1268778874533.JavaMail.root@elwamui-karabash.atl.sa.earthlink.net>
In-Reply-To:
 <30670617.1268778874533.JavaMail.root@elwamui-karabash.atl.sa.earthlink.net>
X-MIE-MailScanner-Information: Scanned at MIE
X-MIE-MailScanner: Found to be clean
X-MIE-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (not
 cached, score=-0.014, required 2, autolearn=disabled, ALL_TRUSTED -1.44,
 RATWARE_GECKO_BUILD 1.43)
X-MIE-MailScanner-From: jason1@pobox.com
Subject: Re: [Tiff] TIFFVStripSize overflow, JPEG decoding
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
 <mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
 <mailto:tiff-request@lists.maptools.org?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org

Lee Cooper wrote:
> Thank you Bob, Ed, for pointing out the limits on JPEG size.
>
> In light of this fact I think the file may be more complex than I
> expected.  The example I listed is actually on the small side and I
> am certain that typical examples cannot be contained within the
> limits you mention.  Looking at tiffdump output for a larger file
> (listed below) I see unlabeled tags with array values.  I'm guessing
> these are pointers into multiple separate JPEGs.  I cannot be sure
> however because the manufacturer's documentation is still not
> available.
>
> Supposing I have a pointer to a region of the file that contains an
> encoded JPEG, and the size of the region in bytes, is there a simple
> way to decode this region?

> ImageWidth (256) LONG (4) 1<159744>
> ImageLength (257) LONG (4) 1<109824>
> RowsPerStrip (278) LONG (4) 1<109824>

So far as I know, JPEG image dimension fields are always 16-bit 
integers, for a maximum dimension of 65535 pixels. You have an alleged 
JPEG image that exceeds that, so something fishy is going on.

I think you're on the right track, that this is a nonstandard format, 
and that the JPEG strip actually contains multiple JPEG images. I think 
there's a reasonable chance that you could extract the images using 
libjpeg, by first seeking to their starting positions in the TIFF file. 
But finding those starting positions will require reverse engineering, 
or documentation.

Note that after decompression, the strip will be extremely large, over 
4GB. Libtiff usually decompresses each strip in its entirety to memory, 
so even if libtiff supported the format, you might well run into a 
limitation somewhere. (For example, it obviously wouldn't work on a 
32-bit system.)

-- 
Jason Summers

_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
