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 segment my $segref = new Image::MetaData::JPEG::Segment('APP2', \$buffer, 'NOPARSE'); my $MP_FORMAT_IDENTIFIER = chr(hex '4D').chr(hex '50').chr(hex '46').chr(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();