adding user data to a DPX header

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
check227
Posts: 5
Joined: 2010-05-11T09:10:58-07:00
Authentication code: 8675308

adding user data to a DPX header

Post by check227 »

Can ImageMagick be used to set the value for the user-defined data field in a DPX header as documented in the DPX specifications: http://www.fileformat.info/format/dpx/egff.htm?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: adding user data to a DPX header

Post by magick »

See http://www.imagemagick.org/script/motion-picture.php. It explains out to set DPX values. If there is a specific field you would like to set that is not currently available, let us know and we'll add support.
check227
Posts: 5
Joined: 2010-05-11T09:10:58-07:00
Authentication code: 8675308

Re: adding user data to a DPX header

Post by check227 »

Sorry for the long delay on a response. I'm noticing in the source code in dpx.c there is a struct that is part of the header definition:

Code: Select all

typedef struct _DPXUserInfo
{
  char
    id[32];
} DPXUserInfo;
But the corresponding struct in the DPX specifications at http://www.fileformat.info/format/dpx/e ... PX-DMYID.2 includes a field for generic user data:

Code: Select all

typedef struct _UserDefinedData
{
	char  UserId[32];    /* User-defined identification string */
	BYTE *Data;          /* User-defined data */
} USERDEFINEDDATA;
I'd appreciate support for this field in the next release very much.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: adding user data to a DPX header

Post by magick »

Support for user data is already built-in for the API but not the command line. Look for ImageMagick 6.6.2-0 Beta tomorrow and use this command:
  • convert image.dpx -set profile dpx:userdata.txt new.dpx
check227
Posts: 5
Joined: 2010-05-11T09:10:58-07:00
Authentication code: 8675308

Re: adding user data to a DPX header

Post by check227 »

Cool thanks a lot. The user.data field is working well now, however I did come across one issue. I noticed that when I wrote certain lengths of data to the user.data field the data would be truncated when I read it back in. For example any output 8161 to 8192 characters in length would get truncated to 8160 characters. In the following block where the user data block is read in from dpx.c I noticed that the size of user data is having the size of dpx.user.id subtracted away.

Code: Select all

if ((dpx.file.user_size != ~0U) && ((size_t) dpx.file.user_size > sizeof(dpx.user.id)))
{
	StringInfo *profile;
	profile = AcquireStringInfo(dpx.file.user_size - sizeof(dpx.user.id));
	offset += ReadBlob(image, GetStringInfoLength(profile), GetStringInfoDatum(profile));
	(void) SetImageProfile(image, "dpx", profile);
	profile = DestroyStringInfo(profile);
}
This subtraction didn't seem correct to me since the size of dpx.user.id was not being added on during the write process. I removed this subtraction - as seen below - and it seems to fix the problem:

Code: Select all

if (dpx.file.user_size != ~0U)
{
	StringInfo *profile;
	profile = AcquireStringInfo(dpx.file.user_size);
	offset += ReadBlob(image, GetStringInfoLength(profile), GetStringInfoDatum(profile));
	(void) SetImageProfile(image, "dpx", profile);
	profile = DestroyStringInfo(profile);
}
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: adding user data to a DPX header

Post by magick »

Thanks for the problem report and patch. We'll get it into ImageMagick 6.6.2-1 Beta by sometime tomorrow.
digobh
Posts: 8
Joined: 2012-08-29T18:19:25-07:00
Authentication code: 67789

Re: adding user data to a DPX header

Post by digobh »

Hi Guys

I am not able to set any value for the user.data option.

When I run the following lines. I get an empty result to retrive the value I just set.

Code: Select all

$convert des-098-289_comp_v04.0006.dpx -define dpx:user.data="SLATE_FLAG" des-098-289_comp_v04.0006.dpx
$identify -format "%[dpx:user.data]"$ des-098-289_comp_v04.0006.dpx
$
I've tried as suggested too the -set profile and I get a complaint for a input file:

Code: Select all

$ convert des-098-289_comp_v04.0006.dpx -set profile dpx:user.data="SLATE_FLAG" des-098-289_comp_v04.0006.dpx
convert: unable to open file `user.data=SLATE_FLAG':  @ error/blob.c/FileToBlob/925.
Im on Linux using:
Version: ImageMagick 6.6.9-7 2012-08-17 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP

Can someone help me to get the right syntax where I could retrieve the value from the metadata afterwards?
I need to be able to add a comment in the metadata and retrive it later.

Thank you very much for your attention

Rodrigo Guimaraes
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: adding user data to a DPX header

Post by fmw42 »

I do not know much about DPX data, but try

-set dpx:user.data "SLATE_FLAG"

not sure about the periods and colon, though.

see

http://www.imagemagick.org/Usage/basics/#set
digobh
Posts: 8
Joined: 2012-08-29T18:19:25-07:00
Authentication code: 67789

Re: adding user data to a DPX header

Post by digobh »

Hi Fred,

Thanks for your reply.
Your command seems to do something but still, I can't get the value back.
When I run the command below, to list all properties. user.data is not even there. Seems we need to add it first?
I had a look at the link you gave me but I couldn't find anything related.

$ identify -format %[*] des-098-289_comp_v04.0002.dpx
date:create=2012-10-24T10:00:33+11:00
date:modify=2012-10-24T10:00:33+11:00
dpx:file.creator=ImageMagick 6.6.9-7 2012-08-17 Q16 http://www.imagemagick.org
dpx:file.ditto.key=1
dpx:file.timestamp=2012-10-24T10:00:33+11:
dpx:file.version=V2.0
dpx:film.frame_position=0
dpx:film.held_count=0
dpx:film.sequence_extent=0
dpx:image.orientation=0
dpx:orientation.aspect_ratio=0x0
dpx:orientation.border=0x0+0+0
dpx:orientation.x_offset=0
dpx:orientation.x_size=0
dpx:orientation.y_offset=0
dpx:orientation.y_size=0
dpx:television.time.code=00:00:00:00
dpx:television.user.bits=00:00:00:00
software=ImageMagick 6.6.9-7 2012-08-17 Q16 http://www.imagemagick.org

Cheers

Rodrigo Guimaraes
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: adding user data to a DPX header

Post by fmw42 »

The link and my comments were about setting the information into your file.
Post Reply