comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Writing PNG file in pure IDL with metadata
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Writing PNG file in pure IDL with metadata [message #92144] Tue, 20 October 2015 00:39 Go to next message
andrewcool777 is currently offline  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 Go to previous messageGo to next message
Mark[1] is currently offline  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 Go to previous messageGo to next message
andrewcool777 is currently offline  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 Go to previous messageGo to next message
Jim  Pendleton is currently offline  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 Go to previous messageGo to next message
andrewcool777 is currently offline  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 Go to previous messageGo to next message
MarioIncandenza is currently offline  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 #92419 is a reply to message #92144] Fri, 11 December 2015 13:25 Go to previous messageGo to next message
mick.mitanirc3 is currently offline  mick.mitanirc3
Messages: 16
Registered: August 2015
Junior Member
I was also impressed that you worked it out. After creating the charts in IDL I use ImageMagick to create custom metadata in my PNG files for display on a website. The images can change as often as daily or as seldom as yearly but must be displayed using static HTML so the dates the data is valid for (or any value that changes) cannot be in the file names. I need to know if something didn't update. With thousands of images I could not expect to visually confirm that all files are up to date. Now a couple of scripts and a program let me know if anything is out of date or missing.
Re: Writing PNG file in pure IDL with metadata [message #92421 is a reply to message #92402] Sat, 12 December 2015 23:53 Go to previous message
andrewcool777 is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL and GPU
Next Topic: Making an array of only the first number of each row in a file

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:35:57 PDT 2025

Total time taken to generate the page: 0.00782 seconds