> From: Raul Miller
> Sent: Wednesday, 11 August 2010 03:01
> 
> So... I use gethttp to retrieve a png image which I want to manipulate
> in J.
> 
> png=:gethttp'http://rosettacode.org/mw/images/c/c6/Pentagon.png'
> 
> What is the simplest way to convert that raw data to an array of pixel
> values?

I think getimg from the media/platimg addon is what you're after.

Assuming that the issue with retrieving binary data to stdout using wget on 
windows gets resolved, this should work:
   ImgURL=: 'http://rosettacode.org/mw/images/c/c6/Pentagon.png'
   require 'media/platimg web/gethttp'
   RGBMatrix=: getimg gethttp ImgURL

To test that this would work you could do:
   ('file'; jpath '~temp/Pentagon.png') gethttp ImgURL
   RGBMatrix=: getimg fread jpath '~temp/Pentagon.png'

Given that it is currently necessary to download to file, readimg is better for 
now:
   ('file'; jpath '~temp/Pentagon.png') gethttp ImgURL
   RGBMatrix=: readimg jpath '~temp/Pentagon.png'

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to