I believe the problem is with the stdint.h file that is currently used in the Windows build of the library.  I don't think it's compatible with newer versions of Visual Studio.  The example below seems to work nicely, and the errors no longer occur.

http://msinttypes.googlecode.com/svn/trunk/stdint.h

Mike

----- Forwarded Message ----
From: Michael Dillon
To: David Moore <dcm@MIT.EDU>
Sent: Sunday, January 28, 2007 9:16:27 PM
Subject: Re: [Libiptcdata-devel] Problem with Nikon pictures

Hi David,

I'm still getting familiar with the code, and I haven't had to dive this deep into JPEGs in quite a while, so please bear with me!

I compared things in CVS, and the critical code appear to be identical.  So, I'm just going to use the packaged download that's on SourceForge.

When using the D200 sample image, I make a call to iptc_jpeg_save_with_ps3().  In that routine, the call to iptc_jpeg_seek_to_ps3() is returning -1.

When I dig deeper into iptc_jpeg_seek_to_ps3(), the first call to iptc_get_short() returns a fairly large negative number (-26980).  This eventually makes 'i' a negative number. The while() loop tries a couple more times, and returns -1 when buf[i] != JPEG_MARKER.

Tracing down to the bottom into iptc_get_sshort(), the IptcByteOrder is passed in as IPTC_BYTE_ORDER_MOTOROLA, and the buffer that is passed in contains:

0x96,0x9c,E,x,i,f (and so on)

So,

((buf[0] << 8) | buf[1])

is returned to iptc_get_short() and then applied with a bitwise '&' against 0xffff to get the negative which seems to throw things off...

Any ideas?

Mike

----- Original Message ----
From: David Moore <dcm@MIT.EDU>
To: Michael Dillon
Cc: libiptcdata-devel@lists.sourceforge.net
Sent: Sunday, January 28, 2007 3:45:06 PM
Subject: Re: [Libiptcdata-devel] Problem with Nikon pictures

I just tried modifying your Nikon_D200.jpg on my Linux machine, and it
worked fine.  I'm using the latest CVS version of libiptcdata, so could
you give that a try also?

If that still doesn't work, this is probably a Windows-only bug.  If
you're willing, I'd really appreciate it if you could track it down in
the code since I don't have access to a Windows machine.

Thanks,

David

On Sun, 2007-01-28 at 14:29 -0800, Michael Dillon wrote:
> Hello,
>
> I'm encountering a problem with writing IPTC to pictures from Nikon
> cameras.  
>
> The details:
>
> I'm using the windows port of version 0.2.1.
> If I attempt operations on any Nikon images (from D200, D80, or 970
> models) I'm unable to write any data.
> If I use the iptctool on the images to read them, it crashes.
> In the debugger, iptc_jpeg_read_ps3() returns a massive value, almost
> the size of the entire image.
> When I call iptc_jpeg_save_with_ps3(), it always returns -1.
> If I use Irfanview to save some IPTC data, then the library works fine
> on the picture.
> My code seems to work fine for other images, but not Nikon...
>
> Some sample images can be found here:
>
> http://www.fileshack.us/v/4494380/Nikon_D200.jpg.html
> http://www.fileshack.us/v/1295234/Nikon_D70.JPG.html
> http://www.fileshack.us/v/1763376/Nikon_D80.JPG.html
>
> Does anyone have a suggested fix or workaround for this?   I haven't
> started to dig into the library code yet...
>
> Mike