<div dir="ltr">A JP2 is just a JPEG2000 codestream with a JPEG2000 header, as soon as you get to the SOC marker then you have all the metadata. Alternatively you could use the JPX file format to store the metadata separately to the codestream.<div><br></div><div>I probably wouldn't use GDAL for this task, just read the metadata until you hit the SOC marker.<br><div><br></div><div><br></div><div>Norman</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 15, 2015 at 1:46 PM, Dr. Joshua Jackson <span dir="ltr"><<a href="mailto:josh@nside.io" target="_blank">josh@nside.io</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I’m looking for a good solution to copy the image meta data from one JP2 to another JP2 in C++. I have a folder full of 4096x4096 JPEG2000 images that I am processing with OpenCV. On some of them I create a copy of the image and do some manipulations to. As expected the new image file is missing all the metadata.</div><div><br></div><div>I have tried using CreateCopy() with the OpenJPEG library; and while this does work it takes a really long time per image ~40sec. (My image manipulations take only ~10sec).</div><div><br></div><div>Is there some way to use the GetGDALDataSet() on the source file and then call SetMetaData() on the destination file for each meta data item? How would one iterate through the metadata items?</div><div><br></div><div>Here is a sample GDALInfo printout for a source image:</div><div><br></div><div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">Driver: JP2OpenJPEG/JPEG-2000 driver based on OpenJPEG library</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">Files: middle_mask.jp2</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">Size is 4096, 4096</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">Coordinate System is:</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">GEOGCS["WGS 84",</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)"> DATUM["WGS_1984",</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)"> SPHEROID["WGS 84",6378137,298.257223563,</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)"> AUTHORITY["EPSG","7030"]],</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)"> AUTHORITY["EPSG","6326"]],</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)"> PRIMEM["Greenwich",0],</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)"> UNIT["degree",0.0174532925199433],</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)"> AUTHORITY["EPSG","4326"]]</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">Origin = (-96.965332031250000,32.464599609375000)</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">Pixel Size = (0.000001341104507,-0.000001341104507)</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">Image Structure Metadata:</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)"> INTERLEAVE=PIXEL</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">Corner Coordinates:</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">Upper Left ( -96.9653320, 32.4645996) ( 96d57'55.20"W, 32d27'52.56"N)</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">Lower Left ( -96.9653320, 32.4591064) ( 96d57'55.20"W, 32d27'32.78"N)</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">Upper Right ( -96.9598389, 32.4645996) ( 96d57'35.42"W, 32d27'52.56"N)</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">Lower Right ( -96.9598389, 32.4591064) ( 96d57'35.42"W, 32d27'32.78"N)</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">Center ( -96.9625854, 32.4618530) ( 96d57'45.31"W, 32d27'42.67"N)</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">Band 1 Block=1024x1024 Type=Byte, ColorInterp=Red</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)"> Overviews: 2048x2048, 1024x1024, 512x512, 256x256</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)"> Overviews: arbitrary</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">Band 2 Block=1024x1024 Type=Byte, ColorInterp=Green</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)"> Overviews: 2048x2048, 1024x1024, 512x512, 256x256</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)"> Overviews: arbitrary</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)">Band 3 Block=1024x1024 Type=Byte, ColorInterp=Blue</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)"> Overviews: 2048x2048, 1024x1024, 512x512, 256x256</div><div style="margin:0px;font-size:11px;font-family:Menlo;background-color:rgb(146,146,146)"> Overviews: arbitrary</div></div><br><div>
<div><div dir="ltr"><table style="border:none;border-collapse:collapse"><tbody><tr style="height:0px"><td style="border:0px solid rgb(255,255,255);vertical-align:top;padding:7px 15px 7px 7px"><p dir="ltr" style="line-height:1.44;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><img src="https://lh5.googleusercontent.com/Enixe41p-q_jIylkS6EEcU0RN_K3ng55pO8HWhnj01mlNrWhNVCJePpkXSGW2eT90LlecokRA31oJUaZYGWSWh8uLWHCPhrhXBYmsoYBWnnxG17GnMUNBFr2ngzH0Tv4sfbmKhA" width="137px;" height="61px;" style="border:none"></span></p></td><td style="border:0px solid rgb(255,255,255);vertical-align:top;padding:7px"><p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt"><span style="font-size:16px;font-family:Arial;color:rgb(18,18,18);font-weight:bold;vertical-align:baseline;white-space:pre-wrap">Joshua Jackson, PhD</span></p><p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;color:rgb(99,99,99);font-weight:bold;vertical-align:baseline;white-space:pre-wrap">Senior ResearchEngineer</span></p><p dir="ltr" style="line-height:1.2;margin-top:2pt;margin-bottom:0pt"><span style="font-family:Arial;color:rgb(99,99,99);font-weight:bold;vertical-align:baseline;white-space:pre-wrap"><img src="https://lh5.googleusercontent.com/xatyzuzTr4qR18HGKcLsrwDas9DT5nxjDwkCZq2oG-ccb408r9aQRo2ECtEatULqLfmK6qV7gtExHhXK9xQE3klp1sk76B2zFUAjZ0jBU9G9fjiwoZTgOYf8xDoQ3jgUClsx0FI" width="11px;" height="12px;" style="border:none"></span><span style="font-family:Arial;color:rgb(221,75,57);font-weight:bold;vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-family:Arial;color:rgb(17,85,204);vertical-align:baseline;white-space:pre-wrap"><a href="tel:8006041822,5109" value="+18006041822" style="color:rgb(17,85,204)" target="_blank">(800) 604-1822 Ext. 5109</a></span><span style="font-family:Arial;color:rgb(130,130,130);vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-family:Arial;color:rgb(130,130,130);vertical-align:baseline;white-space:pre-wrap"><img src="https://lh3.googleusercontent.com/a-PpuK6encseQRC-pViSZ7gztSeVhI2Vas6kFHU--3hOYU3GFekR3Q8P0suxUuqF8xbVUMfIAMyJAZjWSg26CdxKqINZh37L39a4Fw92CF-pLE48m9LaMXB9P9sJBoXV035JqHo" width="7px;" height="11px;" style="border:none"></span><span style="font-family:Arial;color:rgb(221,75,57);vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-family:Arial;color:rgb(17,85,204);vertical-align:baseline;white-space:pre-wrap"><a href="tel:2566485109" value="+12566485112" style="color:rgb(17,85,204)" target="_blank">(256) 648-5109</a></span></p><p dir="ltr" style="line-height:1.2;margin-top:2pt;margin-bottom:0pt"><span style="font-family:Arial;color:rgb(17,85,204);vertical-align:baseline;white-space:pre-wrap"><img src="https://lh3.googleusercontent.com/co3KKKyy46HQYKTzA_uUBeKeze0MmtHwJhER8osdQidG7sjYNblRL5mF9kL4Isk83MheZ7fBtlWxOH2TtR9aIOcl-WPuJJfKd2d-rlRD8V8lZ5T-vfgedI9YPZdvP7_Lke3lWHo" width="13px;" height="11px;" style="border:none"></span><span style="font-family:Arial;color:rgb(130,130,130);vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-family:Arial;color:rgb(17,85,204);vertical-align:baseline;white-space:pre-wrap"><a href="mailto:josh@nside.io" style="color:rgb(17,85,204)" target="_blank">josh@nside.io</a></span><span style="font-family:Arial;color:rgb(130,130,130);vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-family:Arial;color:rgb(130,130,130);vertical-align:baseline;white-space:pre-wrap"><img src="https://lh3.googleusercontent.com/olJmVY9fnwwcyZclvYYYwl2MV3wVZGfiEaK7tFEUkxggNY4Ktf0yUFeYxxQb-Rt-uZQEk-m1lBfxTZxT9rAoVXBbw9lvT648FaYaYjBkhfO1DexnEkxHRhwUV-LNdlHFrYE4PLA" width="12px;" height="12px;" style="border:none"></span><u></u><span style="font-family:Arial;color:rgb(221,75,57);vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><a href="http://www.nSide.io" target="_blank">www.nSide.io</a></span><u></u></p><p dir="ltr" style="line-height:1.2;margin-top:2pt;margin-bottom:0pt"><a href="http://www.nside.io/" style="color:rgb(17,85,204);text-decoration:none" target="_blank"><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><img src="https://lh3.googleusercontent.com/DNCEL6o2IwyEWPCsCo9StUHB31XJHyco59D6mZofeUmOb_zApYHku-xHThh_J1Jlegthj6O4DRIqA0bYbRbHWugyCE8Z7_pHSru836yAReDwIa4sOoUj7oehv9pYIZNY917CGcI" width="12px;" height="11px;" style="border:none"></span></a><span style="font-family:Arial;color:rgb(221,75,57);vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-family:Arial;color:rgb(130,130,130);vertical-align:baseline;white-space:pre-wrap">4031 Parkway Dr, Suite B, Florence, AL 35630</span></p><p dir="ltr" style="line-height:1.2;margin-top:2pt;margin-bottom:0pt"><span style="font-family:Arial;color:rgb(130,130,130);vertical-align:baseline;white-space:pre-wrap"><img src="https://lh6.googleusercontent.com/90X-pf1ZZqJy22YIBBZhA6-N_jli0F4nD14t83iccGDMEAmKLFtAGdgkek1yfExyp5ZcyCSbNSth6NgAPb5ErxJozQBCrXlMN1fbWHgk1YmQfkJ4u07kOQaZT9coaTV9p_-vgk4" width="20px;" height="20px;" style="border:none"></span><a href="http://www.linkedin.com/company/nside/" style="color:rgb(17,85,204);text-decoration:none" target="_blank"><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap"><img src="https://lh6.googleusercontent.com/dg5i18x7n8XMqXoiYQxFzmMF_yk04u1ARSEkJmynHAstoGE4kH5SodMxdpnL5fzcNQbfJkXNhcbNffrXczZLOkv0pVOX64Nh2-PWQA_n_UMhgwrqOd9brGu6eM2Hdcz0cZgsHVI" width="20px;" height="20px;" style="border:none"></span></a><a href="http://twitter.com/nSide__Out" style="color:rgb(17,85,204);text-decoration:none" target="_blank"><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap"><img src="https://lh6.googleusercontent.com/wz-pnG7cTwQlY4FfRpdMylIPaTGn6ZPuPPDWUWeo4suXNL4MEZJcwPO71EyO7b-eburX_YHvonMjuoHTEU2EyBprm0epnG6xq3UGy24hmWGWF1Z1wr0OHlACGKM-_dH0P4ZJIGo" width="20px;" height="20px;" style="border:none"></span></a></p></td></tr></tbody></table></div></div>
</div>
<br></div><br>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote></div><br></div>