Thanks for your reply. I did manage to write in the segment, by creating a new record with store_record and writing directly the record value in the segment buffer
use strict; use warnings; use Image::MetaData::JPEG; use Image::MetaData::JPEG::Record; use Image::MetaData::JPEG::data::Tables qw(:JPEGgrammar :Endianness :RecordTypes); #read the image filname from the command line arguments my $file = new Image::MetaData::JPEG($ARGV[0], 1); #create the APP2 segment, do not parse it as it is empty my $buffer; #the buffer that will contains the data to write in the s +egment my $segref = new Image::MetaData::JPEG::Segment('APP2', \$buffer, 'NOP +ARSE'); my $MP_FORMAT_IDENTIFIER = chr(hex '4D').chr(hex '50').chr(hex '46').c +hr(hex '00'); my $recref_mp_fid = $segref->store_record('MP_FORMAT_IDENTIFIER', $ASCII, \$MP_FORMAT_IDENTIFIER, 4); my $NEXT_IFD_OFFSET = chr(hex '42'). chr(hex '00'). chr(hex '00'). chr(hex '00'); my $next_ifd_offset = $segref->store_record('NEXT_IFD_OFFSET', $BYTE, \$NEXT_IFD_OFFSET, 4); #End of the MPIndex IFD ########################################## ########################################## #write all the records to the segment buffer $buffer = $recref_mp_fid->get(); # ... $buffer .= $next_ifd_offset->get();
It does not matter if APP2 field descriptions are not supported. I only use your module to write chunks of data.

In reply to Re^2: Add a segment in a JPG image with Image::MetaData::JPEG by neoldschool
in thread Add a segment in a JPG image with Image::MetaData::JPEG by neoldschool

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.