 |
|
 |
Thanks for the code. I think that header parser terminated incorrectly when the record 1C02 has marker and length 0. Instead of quiting the parser, the parser should continue and parse the next 1C02 record. Thus the code might look ike this (2 changes):
void CIPTC::ParseHeader(unsigned char *buffer)
{
unsigned long ret,pos = 2,len = 0; //first two bytes are size info
char type;
CString cnt;
//calc length
len = ((unsigned long)(buffer[0]<<8) + ((unsigned long)(buffer[1])));
while(pos < len)
{
ret = GetNextHeaderInfo(buffer+pos,&type,cnt);
//---------- code change 1
pos += 5; //header info: marker(2) + type +size(2)
if(ret == 0)
continue;
pos += ret; // info length
//---------- end of change 1
switch(type)
{
//credits
case '\x50':
m_Byline = cnt;
break;
case '\x55':
m_BylineTitle = cnt;
break;
case '\x6E':
m_Credits = cnt;
break;
case '\x73':
m_Source = cnt;
break;
//origin
case '\x05':
m_ObjectName = cnt;
break;
case '\x37':
m_DateCreated = cnt;
break;
case '\x5A':
m_City = cnt;
break;
case '\x5F':
m_State = cnt;
break;
case '\x65':
m_Country = cnt;
break;
case '\x67':
m_OriginalTransmissionReference = cnt;
break;
//copyright
case '\x74':
m_CopyrightNotice = cnt;
break;
//caption
case '\x78':
m_Caption = cnt;
break;
case '\x7A':
m_CaptionWriter = cnt;
break;
case '\x69':
m_Headline = cnt;
break;
case '\x28':
m_SpecialInstructions = cnt;
break;
//categories
case '\x0F':
m_Category = cnt;
break;
case '\x14':
m_SupplementalCategories.Add(cnt);
break;
//Keywords
case '\x19':
m_Keywords.Add(cnt);
break;
}
//----------- change 2, remove the following line
//pos += ret + 5; //header info: marker(2) + type +size(2)
}
}
|
|
|
|
 |
|
 |
i like it. used it in program to monitor photos from the Associated Press into The Denver Post. however, i already had read the file into memory for rendering in the application, so i overloaded OpenFile to accept a char pointer as a parameter. also, i needed to put it into a vector because the monitor program displays several photos, so i added an equals operator:
In the header:
int OpenFile(const char *buf);
CIPTC& operator=(CIPTC &iptc);
The code:
int CIPTC::OpenFile(const char *buf)
{
unsigned char buffer[30]; unsigned char* app = NULL; unsigned long len = 0;
unsigned char* ptr = NULL;
memcpy (buffer, buf, 11);
if(memcmp(buffer,JPG_Header,11) != 0)
{
return 0;
}
if((app = GetAppHeader((unsigned char *)(buf + 20),"\xFF\xED",len)) != 0) {
if(memcmp(Photoshop_Header,app,14) != 0)
{
return 0;
}
if((ptr = Get8BIMHeader(app,"\x4\x4",len)) == NULL)
{
return 0;
}
ParseHeader(ptr);
}
return (1);
}
and for the operator:
CIPTC& CIPTC::operator=(CIPTC &iptc)
{
m_Byline = iptc.m_Byline;
m_BylineTitle = iptc.m_BylineTitle;
m_Credits = iptc.m_Credits;
m_Source = iptc.m_Source;
m_CaptionWriter = iptc.m_CaptionWriter;
m_Caption = iptc.m_Caption;
m_Headline = iptc.m_Headline;
m_SpecialInstructions = iptc.m_SpecialInstructions;
m_ObjectName = iptc.m_ObjectName;
m_DateCreated = iptc.m_DateCreated;
m_City = iptc.m_City;
m_State = iptc.m_State;
m_Country = iptc.m_Country;
m_OriginalTransmissionReference = iptc.m_OriginalTransmissionReference;
m_Category = iptc.m_Category;
m_CopyrightNotice = iptc.m_CopyrightNotice;
m_SupplementalCategories.Copy(iptc.m_SupplementalCategories);
m_Keywords.Copy(iptc.m_Keywords);
m_AppHeaderLength = iptc.m_AppHeaderLength;
m_AppHeaderStart = iptc.m_AppHeaderStart;
return (*this);
}
thanks for the class!
|
|
|
|
 |
|
 |
would you please help me to read metadata in IPTC format with vb.net/C#?
Pouya
|
|
|
|
 |
|
 |
The table showing the fields in the 8BIM block needs to be updated, it's incorrect.
- The Segment size field is actually a 4 byte Long value, not 2 bytes.
- The prior field is not 4 bytes of padding but it is a variable length Pascal string that's padded out to a two byte boundary. A Pascal string has the first byte as the string length, followed by 0-255 single byte characters. Note that the Pascal string itself is NOT null terminated. However in the 8BIM block it may be followed by 0 or 1 byte of null padding. So there may or may not be a null following the string, and that's OK.
|
|
|
|
 |
|
 |
i try to extract iptc data from AFP news agency photo
it failed to get anything
can any one help me
ibrahim37me@hotmail.com
|
|
|
|
 |
|
 |
I have not used the code but have developped a LISP program to access and modify these data.
Your page is the only page where I have found at last a clear explanation of the 8BIM segements.
Thanks very much.
Jacques R
|
|
|
|
 |
|
 |
Hi..Where can I get information about JPEG header format so I can parse the IPTC data manually? Thanks a lot!!
|
|
|
|
 |
|
 |
The program works quit well also on new files from PS9
My problem is that its crush when I'm trying to save it back.
Any ideas?
|
|
|
|
 |
|
 |
Hi,
most likely you hit the limitation described in the text: "However this currently only works with files that already contain IPTC information."
The code is old and far from perfect
Cheers
Chris
|
|
|
|
 |
|
 |
Hello,
When I want create new IPTC header with this class, it does not work.
But if I modify an existing header, it work, I don't understand...
How I can create a new IPTC header?
Please help me...
|
|
|
|
 |
|
|
 |
|
 |
The photoshop application segment is APP13. 0x0d hexadecimal is 13 decimal. Hence APP13.
|
|
|
|
 |
|
 |
Hi.
I'm using the code to extract IPTC of images JPG. I build a COM in MS VC++ 6. I have a problem. The code only extracts IPTC of some images probably of those that already has IPTC.
When I load IPTC and I alter some fields, if I don't fill out any all the fields information they are not saved.
Does anybody can me to help? Where can I find a code that can solve my problem?:
(
|
|
|
|
 |
|
 |
The const char Photoshop_1C02[] must equal to "\x1c\x02" and NOT "\x1c\02".
And don't use the 'Save' functionality.
It will delete some of the IPCT Headers!
|
|
|
|
 |
|
 |
What exactly will break if I use 'Save' ? Does anyone have a fix for this ?
Best Regards
Michael
|
|
|
|
 |
|
 |
The author got the 8BIM segment format wrong. Here's the actual format:
BYTE Type[4]; /* Always "8BIM" */
WORD ID; /* Various - we're looking for 0x0404 */
BYTE Name[]; /* Even-length Pascal-format string, 2 bytes or longer */
LONG Size; /* Length of resource data following, in bytes */
BYTE Data[]; /* Resource data, padded to even length */
Note that these are unsigned quantities. Name is always an even number of bytes (including the 1st byte, which is the size.)
|
|
|
|
 |
|
 |
Is the function Get8BIMHeader() also wrong because of this?
|
|
|
|
 |
|
 |
hi all,
it is a nice code.but does it support all jpegs? or only his example?
coz i tried to read header of my own photo and it didnt work.will i read only the jpeg created and added header with Adobe 3.0?
take care,
A.Y.
|
|
|
|
 |
|
 |
The code provided is quite old now.
The formats (of newer Photoshop versions) changed, and it certainly doesn't capture each and every
possible format version out there.
So it should be able to handle mor than the sample photos but will probably not handle all the photos you can imagine.
Cheers
Chris
|
|
|
|
 |
|
 |
Thank u very much for ur reply.
Do u have new codes?
How or where can i find a sample code for reading jpeg files and shwing them?
i have a project to finish in 1 week and i couldnt do it yet
pls help me?
take care,
A.Y.
|
|
|
|
 |
|
 |
Hi.
I'm on a big project where I need to use java to parse a photoshop tiff file an extract embedded clip path information.
I have it "working" but it's really a hacky way to do it and will only handle a single clip path. I really need a good example of an 8BIM rader in java.
ultimately, I need to be able to extract multiple embedded paths based on their names.
Can anyone give me any help at all? I'm starting to feel lost.
Thanks!
Jonathan Doklovic
Senior Programmer
Limited Brands Technology Services
http://www.vicotriassecret.com
|
|
|
|
 |
|
 |
Hi,
Please tell me , how can one recognize the IPTC header in a file , if
there is a possibility that the IPTC editor application for the file is not
known, like in all those files which are saved using Photoshop after saving
the IPTC info we cud find Photoshop 3.0 as Photoshop signature. Moreover the
delimiter for various field is 8BIM in this case.So if the file containing the IPTC info. has nothing to do with photoshop then how can we extract the IPTC info.
|
|
|
|
 |
|
 |
Hi,
IPTC (the organisation) defines a standard how to encapsulate their info. Photoshop is compliant to that, in that respect that the IPTC blob inside the 8BIM segement is according to the specs and the whole thing is in the proper JPEG segment.
AFAIK the IPTC spec does not prevent somebody from adding additional info around. So a pure IPTC reader (I have not tried the IPTC sample C code) should be able to read Photoshop generated IPTC info.
The sample application here can be easily modified to handle pure-IPTC images. Just throw out the parsing of the Photoshop specific stuff.
So maybe a valid comparison would be a HTML file that not every browser can parse (=extract all info in it).
Cheers
Chris
|
|
|
|
 |
|
 |
Thanks a lot for ur sanguine attitude that u come back quickly.
So this mean that we can safly rely on the occurence of 8BIM /x04 /x04
as the starting point of IPTC blob.
Actually we r on the way to develop the piece of code which just
extract the IPTC info. from a file (jpeg,tiff or eps).So our interest
confined just to fish out the relevent info and we don't need to add more
info.
Since u scrutinize the IPTC blob & ur r confirming that 8BIM /x04 /x04,
identifier is unique then we need not to look for ADOBE or any other application signature in the file being treated.Up untill now what we were doing that first we were looking for "\x FFED Photoshop 3.0" if we get this only then we were looking forward to search 8BIM /x04 /x04.But since there are a lot no. of application other than (Photoshop) like Exifer,Cumulus etc.
Our code was not able to extract info if application was not having photoshop identifier.
This way the conclusion is that 8BIM /x04 /x04 identifier is unique and we must just look for its first occurence in the file under process.If i am wrong at any point please try to comment.
Thanks and Regards,
Priyanka Ahuja
Member-Software Development Group
Quark System Pvt. Ltd.
|
|
|
|
 |
|
 |
Not exactly. 8BIM is Photoshop specific. 1C02 headers are IPTC.
You'll have to scan for them.
|
|
|
|
 |