{"action":"created","issue":{"url":"https://api.github.com/repos/clementfarabet/graphicsmagick/issues/31","labels_url":"https://api.github.com/repos/clementfarabet/graphicsmagick/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/clementfarabet/graphicsmagick/issues/31/comments","events_url":"https://api.github.com/repos/clementfarabet/graphicsmagick/issues/31/events","html_url":"https://github.com/clementfarabet/graphicsmagick/issues/31","id":119268142,"number":31,"title":"documentation on pixel access","user":{"login":"bobombolo","id":12679496,"avatar_url":"https://avatars.githubusercontent.com/u/12679496?v=3","gravatar_id":"","url":"https://api.github.com/users/bobombolo","html_url":"https://github.com/bobombolo","followers_url":"https://api.github.com/users/bobombolo/followers","following_url":"https://api.github.com/users/bobombolo/following{/other_user}","gists_url":"https://api.github.com/users/bobombolo/gists{/gist_id}","starred_url":"https://api.github.com/users/bobombolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bobombolo/subscriptions","organizations_url":"https://api.github.com/users/bobombolo/orgs","repos_url":"https://api.github.com/users/bobombolo/repos","events_url":"https://api.github.com/users/bobombolo/events{/privacy}","received_events_url":"https://api.github.com/users/bobombolo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-28T03:27:10Z","updated_at":"2015-11-28T04:53:24Z","closed_at":null,"body":"what is the syntax for getting the value of a pixel?\r\n\r\nI have loaded an image and have tried:\r\n\r\nwidth, length = myimage:size() --this works\r\n\r\nbut there does not appear to be a method in Image.lua that gives pixel access, does one need to be written? something like, Image:get_pixel(x,y) that returns a value and/or Image:get_pixels(x,y,w,h) that returns a table of values indexed by column, row.\r\n\r\nor can MagickGetImagePixels be used?\r\n"},"comment":{"url":"https://api.github.com/repos/clementfarabet/graphicsmagick/issues/comments/160248585","html_url":"https://github.com/clementfarabet/graphicsmagick/issues/31#issuecomment-160248585","issue_url":"https://api.github.com/repos/clementfarabet/graphicsmagick/issues/31","id":160248585,"user":{"login":"bobombolo","id":12679496,"avatar_url":"https://avatars.githubusercontent.com/u/12679496?v=3","gravatar_id":"","url":"https://api.github.com/users/bobombolo","html_url":"https://github.com/bobombolo","followers_url":"https://api.github.com/users/bobombolo/followers","following_url":"https://api.github.com/users/bobombolo/following{/other_user}","gists_url":"https://api.github.com/users/bobombolo/gists{/gist_id}","starred_url":"https://api.github.com/users/bobombolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bobombolo/subscriptions","organizations_url":"https://api.github.com/users/bobombolo/orgs","repos_url":"https://api.github.com/users/bobombolo/repos","events_url":"https://api.github.com/users/bobombolo/events{/privacy}","received_events_url":"https://api.github.com/users/bobombolo/received_events","type":"User","site_admin":false},"created_at":"2015-11-28T04:53:24Z","updated_at":"2015-11-28T04:53:24Z","body":"sorry I am a very basic developer, are you saying that I need to add a declaration to http://www.graphicsmagick.org/api/pixel_cache.html#acquireonepixel or http://www.graphicsmagick.org/api/pixel_cache.html#getonepixel ?  is that done in the Image.lua file at the top between the [[ and ]] \r\n\r\ni suppose I could use a series of methods, clone():crop():format():tostring() I could get one pixel as a string containing raw bytes... \r\n\r\nI tried adding declarations for PixelPacket and the getOnePixel() but I don't really know what I am doing with that. \r\n\r\n\r\nI did manage to add declarations for \r\n\r\ndouble PixelGetRed( const PixelWand *wand );\r\n  double PixelGetGreen( const PixelWand *wand );\r\n  double PixelGetBlue( const PixelWand *wand );\r\n\r\nand then wrote this function:\r\n\r\n<pre>\r\n--get pixel(s)\r\nfunction Image:getPixel(x, y)\r\n  -- Create PixelWand:\r\n   local pixelwand = ffi.gc(clib.NewPixelWand(), function(pixelwand)\r\n      -- Collect:\r\n      clib.DestroyPixelWand(pixelwand)\r\n   end)\r\n   local r,g,b\r\n   r = clib.PixelGetRed(pixelwand)\r\n   g = clib.PixelGetGreen(pixelwand)\r\n   b = clib.PixelGetBlue(pixelwand)\r\n    print(r)\r\n   return r,g,b\r\nend\r\n</pre>\r\n\r\nbut of course this doesn't return anything other than 0 because no x,y coordinate is set anywhere. it is probably better to use the pixelPacket approach anyway. not sure where to go from here...\r\n\r\ncan anyone help?\r\ntorch is not an option for my project but this library is mostly working for me, except this one thing. pixel access appears to be a basic feature in all the image libraries I've seen. could I request this feature to be added? it would probably be trivial for the maintainers or anyone familiar with declarations to add a method that interfaces with getonepixel, and one that interfaces with getpixels ( http://www.graphicsmagick.org/api/pixel_cache.html#getpixels ), this library already uses getImagePixels... in the toTensor() method... with this feature your library would be useful to many other users who are looking to switch from imagemagick in a lua environment...\r\n"}}