HI ! I want to add an APP segment in a jpg image with the Image::MetaData::JPEG module.
The following code add an APP2 segment inside the jpg, but it seems to be empty as it only add \0xffe200002 in the file, which means: an APP2 segment (\0xffe2) of length 2 (\0x0002) (the marker plus the length's length = 2, basically an empty segment).
perl run.pl test.jpguse strict; use warnings; use Image::MetaData::JPEG; use Image::MetaData::JPEG::Record; use Image::MetaData::JPEG::data::Tables qw(:JPEGgrammar :Endianness :RecordTypes); use Data::Dumper; #read the image filname from the command line arguments my $file = new Image::MetaData::JPEG($ARGV[0]); #add MP header information in the APP2 segment in the image my $buffer; my $segref = new Image::MetaData::JPEG::Segment('APP2', $buffer, 'NOPA +RSE'); my $head = "MPF0"; my $recref = $segref->store_record('MP_HEADER', $LONG, \$head, 1); print Dumper $segref; $file->insert_segments($segref); #save $file->save('tmp1.jpg');
Output
How can I add a segement in a JPG with this module, how to use the insert_segments function properly ? especially the $buffer variable. thanks !$VAR1 = bless( { 'dataref' => \'', 'endianness' => undef, 'error' => undef, 'records' => [ bless( { 'values' => [ 1297106480 ], 'extra' => undef, 'key' => 'MP_HEADER', 'type' => 4 }, 'Image::MetaData::JPEG::Reco +rd' ) ], 'name' => 'APP2' }, 'Image::MetaData::JPEG::Segment' );
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |