Writing PNG file in pure IDL with metadata [message #92144] |
Tue, 20 October 2015 00:39  |
andrewcool777
Messages: 27 Registered: November 2012
|
Junior Member |
|
|
Hi All,
I have a bunch of Canon RAW .CR2 files that I'd like to transmogrify
into PNG files with nice informative metadata embedded in them.
Unfortunately IDL's inbuilt READ_PNG and WRITE_PNG don't know that PNG files can take metadata, and it looks like I'll be old, fat and bald before they do.
Wait, I am old, fat and bald... :-(
Anyway, I wondering if anyone has invented this particular wheel before.
I'd be happy to work with a pure IDL write routine, or some method of Spawning off a command to a 3rd party program.
TIA,
Andrew
|
|
|
Re: Writing PNG file in pure IDL with metadata [message #92145 is a reply to message #92144] |
Tue, 20 October 2015 04:23   |
Mark[1]
Messages: 66 Registered: February 2008
|
Member |
|
|
On Tuesday, 20 October 2015 20:39:13 UTC+13, andrew...@gmail.com wrote:
> Hi All,
>
> I have a bunch of Canon RAW .CR2 files that I'd like to transmogrify
> into PNG files with nice informative metadata embedded in them.
>
> Unfortunately IDL's inbuilt READ_PNG and WRITE_PNG don't know that PNG files can take metadata, and it looks like I'll be old, fat and bald before they do.
> Wait, I am old, fat and bald... :-(
>
> Anyway, I wondering if anyone has invented this particular wheel before.
> I'd be happy to work with a pure IDL write routine, or some method of Spawning off a command to a 3rd party program.
>
> TIA,
>
> Andrew
ImageMagick should do this:
http://www.imagemagick.org/Usage/basics/#attributes
It's available on Linux, obviously, and on Windows via Cygwin. I haven't used ImageMagick for this purpose but I do regularly use it from IDL for format conversion (usually on windows via Cygwin).
|
|
|
Re: Writing PNG file in pure IDL with metadata [message #92146 is a reply to message #92145] |
Tue, 20 October 2015 04:28   |
andrewcool777
Messages: 27 Registered: November 2012
|
Junior Member |
|
|
On Tuesday, 20 October 2015 21:53:42 UTC+10:30, Mark Hadfield wrote:
> On Tuesday, 20 October 2015 20:39:13 UTC+13, andrew...@gmail.com wrote:
>> Hi All,
>>
>> I have a bunch of Canon RAW .CR2 files that I'd like to transmogrify
>> into PNG files with nice informative metadata embedded in them.
>>
>> Unfortunately IDL's inbuilt READ_PNG and WRITE_PNG don't know that PNG files can take metadata, and it looks like I'll be old, fat and bald before they do.
>> Wait, I am old, fat and bald... :-(
>>
>> Anyway, I wondering if anyone has invented this particular wheel before.
>> I'd be happy to work with a pure IDL write routine, or some method of Spawning off a command to a 3rd party program.
>>
>> TIA,
>>
>> Andrew
>
> ImageMagick should do this:
>
> http://www.imagemagick.org/Usage/basics/#attributes
>
> It's available on Linux, obviously, and on Windows via Cygwin. I haven't used ImageMagick for this purpose but I do regularly use it from IDL for format conversion (usually on windows via Cygwin).
Thanks Mark. I was thinking I'd have to wait for a reply until the Yanks woke up, but I forgot about you worthy New Zealanders... ;-)
Andrew
|
|
|
Re: Writing PNG file in pure IDL with metadata [message #92160 is a reply to message #92146] |
Wed, 21 October 2015 10:13   |
Jim Pendleton
Messages: 165 Registered: November 2011
|
Senior Member |
|
|
On Tuesday, October 20, 2015 at 5:28:09 AM UTC-6, andrew...@gmail.com wrote:
> On Tuesday, 20 October 2015 21:53:42 UTC+10:30, Mark Hadfield wrote:
>> On Tuesday, 20 October 2015 20:39:13 UTC+13, andrew...@gmail.com wrote:
>>> Hi All,
>>>
>>> I have a bunch of Canon RAW .CR2 files that I'd like to transmogrify
>>> into PNG files with nice informative metadata embedded in them.
>>>
>>> Unfortunately IDL's inbuilt READ_PNG and WRITE_PNG don't know that PNG files can take metadata, and it looks like I'll be old, fat and bald before they do.
>>> Wait, I am old, fat and bald... :-(
>>>
>>> Anyway, I wondering if anyone has invented this particular wheel before.
>>> I'd be happy to work with a pure IDL write routine, or some method of Spawning off a command to a 3rd party program.
>>>
>>> TIA,
>>>
>>> Andrew
>>
>> ImageMagick should do this:
>>
>> http://www.imagemagick.org/Usage/basics/#attributes
>>
>> It's available on Linux, obviously, and on Windows via Cygwin. I haven't used ImageMagick for this purpose but I do regularly use it from IDL for format conversion (usually on windows via Cygwin).
>
> Thanks Mark. I was thinking I'd have to wait for a reply until the Yanks woke up, but I forgot about you worthy New Zealanders... ;-)
>
> Andrew
Andrew,
Though I can't share it, I wrote a procedure that supports writing both zTXt and tEXt to existing PNG files in fewer than 200 lines of IDL including lots of comments. It could be reduced even more with ZLIB_COMPRESS that was introduced to IDL since my original effort. I had to hack that with a temp file using /COMPRESS at the time.
The only remotely tricky part of the code is the application of the CRC. You can find the reference C implementation of the CRC here in Section 3.4: http://www.libpng.org/pub/png/spec/1.2/PNG-Structure.html#CR C-algorithm
I'd bet you can slap together a working version in less than an hour, which is significantly less time than you might wait for the feature to show up in a released version of IDL.
Jim P
"I work for Harris, but speak not for the Corporation"
|
|
|
Re: Writing PNG file in pure IDL with metadata [message #92396 is a reply to message #92160] |
Mon, 07 December 2015 19:16   |
andrewcool777
Messages: 27 Registered: November 2012
|
Junior Member |
|
|
On Thursday, 22 October 2015 03:43:41 UTC+10:30, Jim P wrote:
> On Tuesday, October 20, 2015 at 5:28:09 AM UTC-6, andrew...@gmail.com wrote:
>> On Tuesday, 20 October 2015 21:53:42 UTC+10:30, Mark Hadfield wrote:
>>> On Tuesday, 20 October 2015 20:39:13 UTC+13, andrew...@gmail.com wrote:
>>>> Hi All,
>>>>
>>>> I have a bunch of Canon RAW .CR2 files that I'd like to transmogrify
>>>> into PNG files with nice informative metadata embedded in them.
>>>>
>>>> Unfortunately IDL's inbuilt READ_PNG and WRITE_PNG don't know that PNG files can take metadata, and it looks like I'll be old, fat and bald before they do.
>>>> Wait, I am old, fat and bald... :-(
>>>>
>>>> Anyway, I wondering if anyone has invented this particular wheel before.
>>>> I'd be happy to work with a pure IDL write routine, or some method of Spawning off a command to a 3rd party program.
>>>>
>>>> TIA,
>>>>
>>>> Andrew
>>>
>>> ImageMagick should do this:
>>>
>>> http://www.imagemagick.org/Usage/basics/#attributes
>>>
>>> It's available on Linux, obviously, and on Windows via Cygwin. I haven't used ImageMagick for this purpose but I do regularly use it from IDL for format conversion (usually on windows via Cygwin).
>>
>> Thanks Mark. I was thinking I'd have to wait for a reply until the Yanks woke up, but I forgot about you worthy New Zealanders... ;-)
>>
>> Andrew
>
> Andrew,
>
> Though I can't share it, I wrote a procedure that supports writing both zTXt and tEXt to existing PNG files in fewer than 200 lines of IDL including lots of comments. It could be reduced even more with ZLIB_COMPRESS that was introduced to IDL since my original effort. I had to hack that with a temp file using /COMPRESS at the time.
>
> The only remotely tricky part of the code is the application of the CRC. You can find the reference C implementation of the CRC here in Section 3.4: http://www.libpng.org/pub/png/spec/1.2/PNG-Structure.html#CR C-algorithm
>
> I'd bet you can slap together a working version in less than an hour, which is significantly less time than you might wait for the feature to show up in a released version of IDL.
>
> Jim P
> "I work for Harris, but speak not for the Corporation"
Thanks Jim,
Yes, I eventually bit the bullet and wrote the whole kit 'n' kaboodle in IDL,
without any calls to external libraries.
So, it's not the fastest PNG writer you'll ever see, but it does write out
a standard format Metadata header with our customised fields, and the resulting files can be read by 3rd party PNG readers.
It would still be nice to see IDL handle metadata reading and writing for all image formats that support metadata.
Cheers,
Andrew
|
|
|
Re: Writing PNG file in pure IDL with metadata [message #92402 is a reply to message #92396] |
Tue, 08 December 2015 13:52   |
MarioIncandenza
Messages: 231 Registered: February 2005
|
Senior Member |
|
|
On Monday, December 7, 2015 at 7:16:35 PM UTC-8, andrew...@gmail.com wrote:
> On Thursday, 22 October 2015 03:43:41 UTC+10:30, Jim P wrote:
>> On Tuesday, October 20, 2015 at 5:28:09 AM UTC-6, andrew...@gmail.com wrote:
>>> On Tuesday, 20 October 2015 21:53:42 UTC+10:30, Mark Hadfield wrote:
>>>> On Tuesday, 20 October 2015 20:39:13 UTC+13, andrew...@gmail.com wrote:
>>>> > Hi All,
>>>> >
>>>> > I have a bunch of Canon RAW .CR2 files that I'd like to transmogrify
>>>> > into PNG files with nice informative metadata embedded in them.
>>>> >
>>>> > Unfortunately IDL's inbuilt READ_PNG and WRITE_PNG don't know that PNG files can take metadata, and it looks like I'll be old, fat and bald before they do.
>>>> > Wait, I am old, fat and bald... :-(
>>>> >
>>>> > Anyway, I wondering if anyone has invented this particular wheel before.
>>>> > I'd be happy to work with a pure IDL write routine, or some method of Spawning off a command to a 3rd party program.
>>>> >
>>>> > TIA,
>>>> >
>>>> > Andrew
>>>>
>>>> ImageMagick should do this:
>>>>
>>>> http://www.imagemagick.org/Usage/basics/#attributes
>>>>
>>>> It's available on Linux, obviously, and on Windows via Cygwin. I haven't used ImageMagick for this purpose but I do regularly use it from IDL for format conversion (usually on windows via Cygwin).
>>>
>>> Thanks Mark. I was thinking I'd have to wait for a reply until the Yanks woke up, but I forgot about you worthy New Zealanders... ;-)
>>>
>>> Andrew
>>
>> Andrew,
>>
>> Though I can't share it, I wrote a procedure that supports writing both zTXt and tEXt to existing PNG files in fewer than 200 lines of IDL including lots of comments. It could be reduced even more with ZLIB_COMPRESS that was introduced to IDL since my original effort. I had to hack that with a temp file using /COMPRESS at the time.
>>
>> The only remotely tricky part of the code is the application of the CRC. You can find the reference C implementation of the CRC here in Section 3.4: http://www.libpng.org/pub/png/spec/1.2/PNG-Structure.html#CR C-algorithm
>>
>> I'd bet you can slap together a working version in less than an hour, which is significantly less time than you might wait for the feature to show up in a released version of IDL.
>>
>> Jim P
>> "I work for Harris, but speak not for the Corporation"
>
> Thanks Jim,
>
> Yes, I eventually bit the bullet and wrote the whole kit 'n' kaboodle in IDL,
> without any calls to external libraries.
>
> So, it's not the fastest PNG writer you'll ever see, but it does write out
> a standard format Metadata header with our customised fields, and the resulting files can be read by 3rd party PNG readers.
>
> It would still be nice to see IDL handle metadata reading and writing for all image formats that support metadata.
>
> Cheers,
>
> Andrew
Andrew,
I'm impressed you went through with this. A question: what 3rd party applications have you encountered that can get at the metadata in a PNG file? The only one I know of is the aforementioned ImageMagick.
|
|
|
|
Re: Writing PNG file in pure IDL with metadata [message #92421 is a reply to message #92402] |
Sat, 12 December 2015 23:53  |
andrewcool777
Messages: 27 Registered: November 2012
|
Junior Member |
|
|
On Wednesday, 9 December 2015 08:22:38 UTC+10:30, Edward Hyer wrote:
> On Monday, December 7, 2015 at 7:16:35 PM UTC-8, andrew...@gmail.com wrote:
>> On Thursday, 22 October 2015 03:43:41 UTC+10:30, Jim P wrote:
>>> On Tuesday, October 20, 2015 at 5:28:09 AM UTC-6, andrew...@gmail.com wrote:
>>>> On Tuesday, 20 October 2015 21:53:42 UTC+10:30, Mark Hadfield wrote:
>>>> > On Tuesday, 20 October 2015 20:39:13 UTC+13, andrew...@gmail.com wrote:
>>>> > > Hi All,
>>>> > >
>>>> > > I have a bunch of Canon RAW .CR2 files that I'd like to transmogrify
>>>> > > into PNG files with nice informative metadata embedded in them.
>>>> > >
>>>> > > Unfortunately IDL's inbuilt READ_PNG and WRITE_PNG don't know that PNG files can take metadata, and it looks like I'll be old, fat and bald before they do.
>>>> > > Wait, I am old, fat and bald... :-(
>>>> > >
>>>> > > Anyway, I wondering if anyone has invented this particular wheel before.
>>>> > > I'd be happy to work with a pure IDL write routine, or some method of Spawning off a command to a 3rd party program.
>>>> > >
>>>> > > TIA,
>>>> > >
>>>> > > Andrew
>>>> >
>>>> > ImageMagick should do this:
>>>> >
>>>> > http://www.imagemagick.org/Usage/basics/#attributes
>>>> >
>>>> > It's available on Linux, obviously, and on Windows via Cygwin. I haven't used ImageMagick for this purpose but I do regularly use it from IDL for format conversion (usually on windows via Cygwin).
>>>>
>>>> Thanks Mark. I was thinking I'd have to wait for a reply until the Yanks woke up, but I forgot about you worthy New Zealanders... ;-)
>>>>
>>>> Andrew
>>>
>>> Andrew,
>>>
>>> Though I can't share it, I wrote a procedure that supports writing both zTXt and tEXt to existing PNG files in fewer than 200 lines of IDL including lots of comments. It could be reduced even more with ZLIB_COMPRESS that was introduced to IDL since my original effort. I had to hack that with a temp file using /COMPRESS at the time.
>>>
>>> The only remotely tricky part of the code is the application of the CRC. You can find the reference C implementation of the CRC here in Section 3.4: http://www.libpng.org/pub/png/spec/1.2/PNG-Structure.html#CR C-algorithm
>>>
>>> I'd bet you can slap together a working version in less than an hour, which is significantly less time than you might wait for the feature to show up in a released version of IDL.
>>>
>>> Jim P
>>> "I work for Harris, but speak not for the Corporation"
>>
>> Thanks Jim,
>>
>> Yes, I eventually bit the bullet and wrote the whole kit 'n' kaboodle in IDL,
>> without any calls to external libraries.
>>
>> So, it's not the fastest PNG writer you'll ever see, but it does write out
>> a standard format Metadata header with our customised fields, and the resulting files can be read by 3rd party PNG readers.
>>
>> It would still be nice to see IDL handle metadata reading and writing for all image formats that support metadata.
>>
>> Cheers,
>>
>> Andrew
>
> Andrew,
>
> I'm impressed you went through with this. A question: what 3rd party applications have you encountered that can get at the metadata in a PNG file? The only one I know of is the aforementioned ImageMagick.
Hi Ed,
I'd love to say that IDL could access the PNG metadata, but of course it can't. I've had a change request in for quite some time for RSI/Kodak/Exelisvis/Harris
to extract their digit and fix this.
I generate about 32,000 PNG files a day that are uploaded to my hobby astronomy weather site at www.skippysky.com.au (all in IDL), and professionally I study airglow where the main app I use is the software from Keo Scientific in Calgary that drives our airglow camera. We have a need to insert customised metadata fields unique to our data collection,and also to convert other images from various formats into PNG to fit into our data processing workflow.
The creation of PNG files can happen in batch jobs, so the fact that my IDL PNG writer makes a snail look fast is of no great concern.
Sure, I'd still like IDL's PNG routines to be brought kicking and screaming into the 21st Century, but I may be retired by then... ;-)
Andrew
|
|
|