[BangPypers] [X-Post] [JOB] Fwd: WebApp requirement @ GSLabs, Pune
Sorry about the cross-post but I assume that might be people outside Pune who may be interested. I'm forwarding this mail on behalf of someone I know. People interested in this may please contact Mr. Harsh Vardhan (consultdadoo at gmail.com) directly. The job is based in Pune AFAIK. cheers, - steve Original Message Subject:WebApp requirement @ GSLabs, Pune Date: Fri, 7 Jan 2011 14:39:23 +0530 *Must have:* Strong knowledge of web application development in C/C++/Python/Django. *Good to have:* Networking, VOIP, Billing, NMS, Flash/Flex etc. *Exp: 5+* ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
[BangPypers] moving/clicking the mouse cursor using python
In my application, I need to move mouse-pointer and generate click event. I am not making any GUI application. mouse and click event will be trigger on dekstop. Quick and dirty way to do this import os def move_mouse(x,y): os.system('xdotool mousemove ' + str(x) + ' ' + str(y)) def leftclick(): os.system('xdotool click 1') def rightclick(): os.system('xdotool click 3') Do anybody know better solution, I want to make a cross platform application. I also found some way do it using C library like this from ctypes import cdll def move_mouse1(x,y): dll = cdll.LoadLibrary('libX11.so') d = dll.XOpenDisplay(None) root = dll.XDefaultRootWindow(d) dll.XWarpPointer(d,None,root,0,0,0,0,x,y) dll.XCloseDisplay(d) But still i am searching for better way.. If anybody know, let me know -- ┌─┐ │Narendra Sisodiya │http://narendrasisodiya.com └─┘ ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] moving/clicking the mouse cursor using python
On Fri, Jan 7, 2011 at 4:48 PM, Anand Balachandran Pillai abpil...@gmail.com wrote: You should be using ncurses for applications like this which need mouse positions (x,y) on the console. http://pyncurses.sourceforge.net/ What will be the difference ? can I use pyncurses to generate global mousemovement ? like the way i did with xdotool. Also, What about Windows/Mac Platform ? Please don't use X like the way you did in the 2nd approach, *nix really can do better than that. This ain't 1999 you know. Thanks for tip, but I never write such code so i am asking. --Anand On Fri, Jan 7, 2011 at 4:36 PM, Narendra Sisodiya naren...@narendrasisodiya.com wrote: In my application, I need to move mouse-pointer and generate click event. I am not making any GUI application. mouse and click event will be trigger on dekstop. Quick and dirty way to do this import os def move_mouse(x,y): os.system('xdotool mousemove ' + str(x) + ' ' + str(y)) def leftclick(): os.system('xdotool click 1') def rightclick(): os.system('xdotool click 3') Do anybody know better solution, I want to make a cross platform application. I also found some way do it using C library like this from ctypes import cdll def move_mouse1(x,y): dll = cdll.LoadLibrary('libX11.so') d = dll.XOpenDisplay(None) root = dll.XDefaultRootWindow(d) dll.XWarpPointer(d,None,root,0,0,0,0,x,y) dll.XCloseDisplay(d) But still i am searching for better way.. If anybody know, let me know -- ┌─┐ │ Narendra Sisodiya │ http://narendrasisodiya.com └─┘ ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers -- --Anand ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers -- ┌─┐ │ Narendra Sisodiya │ http://narendrasisodiya.com └─┘ ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] moving/clicking the mouse cursor using python
On Fri, Jan 7, 2011 at 4:54 PM, Narendra Sisodiya naren...@narendrasisodiya.com wrote: On Fri, Jan 7, 2011 at 4:48 PM, Anand Balachandran Pillai abpil...@gmail.com wrote: You should be using ncurses for applications like this which need mouse positions (x,y) on the console. http://pyncurses.sourceforge.net/ What will be the difference ? can I use pyncurses to generate global mousemovement ? like the way i did with xdotool. Also, What about Windows/Mac Platform ? Not sure what you mean by global, but ncurses turns your console into a matrix of x,y positions. It was widely used to provide a console interface to cli programs in the 90s, (I am reminded of my old favorite program mikmod for playing module music), but much less used now a days. I didn't read your post fully. If you want to generate clicks anywhere on desktop, ncurses won't work since it is tied to a terminal. You could try something like http://python-xlib.sourceforge.net/ See some discussion of this on http://stackoverflow.com/questions/2676434/x11-how-to-raise-another-applications-window-using-python Regarding ncurses, yes it will work on any console/terminal which supporse curses. That includes darwin (mac os x) and cygwin on windows. But of course not the DOS terminal. Please don't use X like the way you did in the 2nd approach, *nix really can do better than that. This ain't 1999 you know. Thanks for tip, but I never write such code so i am asking. --Anand -- --Anand ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] moving/clicking the mouse cursor using python
On Fri, Jan 07 2011, Narendra Sisodiya wrote: In my application, I need to move mouse-pointer and generate click event. I am not making any GUI application. mouse and click event will be trigger on dekstop. Is this for some kind of testing? If so, the Linux Desktop Testing Project might offer you something more robust - http://ldtp.freedesktop.org/ [...] Do anybody know better solution, I want to make a cross platform application. Oooh. Windows too? X doesn't run there and so you'll have to resort to something else. I did something like this using pyWin32 http://sourceforge.net/projects/pywin32/ but that was Windows only. I'm not sure but you'll probably have to write multiple backends (for windows and X anyway) and abstract them with a common layer - This might be a useful project in general if you can architect it right. I also found some way do it using C library like this from ctypes import cdll def move_mouse1(x,y): dll = cdll.LoadLibrary('libX11.so') d = dll.XOpenDisplay(None) root = dll.XDefaultRootWindow(d) dll.XWarpPointer(d,None,root,0,0,0,0,x,y) dll.XCloseDisplay(d) But still i am searching for better way.. If anybody know, let me know You might be able to use the Python bindings to Xlib to do this similar to the way you did it using ctypes - http://python-xlib.sourceforge.net/. This talks to the X directly and bypasses any C libraries. It's a pure Python implementation and should work for any X implementation. Your ctypes approach is limited to your platform. It's not very actively maintained though. -- ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] moving/clicking the mouse cursor using python
On Fri, Jan 07 2011, Anand Balachandran Pillai wrote: You should be using ncurses for applications like this which need mouse positions (x,y) on the console. http://pyncurses.sourceforge.net/ Isn't ncurses used for CUI applications? I wasn't aware that you can control your graphical cursor using it or did I misunderstand something? [...] -- ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] moving/clicking the mouse cursor using python
On Fri, Jan 7, 2011 at 5:08 PM, Noufal Ibrahim nou...@gmail.com wrote: On Fri, Jan 07 2011, Anand Balachandran Pillai wrote: You should be using ncurses for applications like this which need mouse positions (x,y) on the console. http://pyncurses.sourceforge.net/ Isn't ncurses used for CUI applications? I wasn't aware that you can control your graphical cursor using it or did I misunderstand something? It can't. Please read my 2nd post fully. [...] -- ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers -- --Anand ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
[BangPypers] Convert to Black and White to an image
Can somebody give an easy way to convert a image into black and white using a given threshold.. Currently I am doing like this image=ImageOps.grayscale(image) for i in range(0,width): for j in range(0,height): if image.getpixel((i,j)) = 200: image.putpixel((i,j),0) What is the general mailing list to ask question on python ? -- ┌─┐ │Narendra Sisodiya │http://narendrasisodiya.com └─┘ ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Convert to Black and White to an image
On 01/07/2011 10:04 PM, Narendra Sisodiya wrote: Can somebody give an easy way to convert a image into black and white using a given threshold.. Currently I am doing like this image=ImageOps.grayscale(image) for i in range(0,width): for j in range(0,height): if image.getpixel((i,j))= 200: image.putpixel((i,j),0) another way to grayscale an image is: from PIL import Image a = Image.open(image_0065.jpg)#color image b= a.convert(L) b is a grayscale image now ;) What is the general mailing list to ask question on python ? The Image SIG mailing list would be a more appropriate place image-...@python.org -- regards --- Kunal Ghosh Dept of Computer Sc. Engineering. Sir MVIT Bangalore,India permalink: member.acm.org/~kunal.t2 Blog:kunalghosh.wordpress.com Website:www.kunalghosh.net46.net ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Convert to Black and White to an image
On Fri, Jan 7, 2011 at 10:27 PM, kunal kunal...@gmail.com wrote: On 01/07/2011 10:04 PM, Narendra Sisodiya wrote: Can somebody give an easy way to convert a image into black and white using a given threshold.. Currently I am doing like this image=ImageOps.grayscale(image) for i in range(0,width): for j in range(0,height): if image.getpixel((i,j))= 200: image.putpixel((i,j),0) another way to grayscale an image is: from PIL import Image a = Image.open(image_0065.jpg)#color image b= a.convert(L) b is a grayscale image now ;) Thanks, but i was aware for this, Still my query is unsolved.. What is the general mailing list to ask question on python ? The Image SIG mailing list would be a more appropriate place image-...@python.org -- regards --- Kunal Ghosh Dept of Computer Sc. Engineering. Sir MVIT Bangalore,India permalink: member.acm.org/~kunal.t2 http://member.acm.org/%7Ekunal.t2 Blog:kunalghosh.wordpress.com Website:www.kunalghosh.net46.net ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers -- ┌─┐ │Narendra Sisodiya │http://narendrasisodiya.com └─┘ ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Convert to Black and White to an image
On Fri, Jan 7, 2011 at 10:04 PM, Narendra Sisodiya naren...@narendrasisodiya.com wrote: Currently I am doing like this image=ImageOps.grayscale(image) for i in range(0,width): for j in range(0,height): if image.getpixel((i,j)) = 200: image.putpixel((i,j),0) Try this (I havent tried it , but something like this should work) : n = image.getpixel((i,j)) if n[0] 127: #R value (r,g,b)=(255,255,255) else: (r,g,b)=(0,0,0) image.putpixel((i,j), (r,g,b) ) -V http://blizzardzblogs.blogspot.com/ ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Convert to Black and White to an image
On Fri, Jan 7, 2011 at 22:04, Narendra Sisodiya naren...@narendrasisodiya.com wrote: Can somebody give an easy way to convert a image into black and white using a given threshold.. Currently I am doing like this image=ImageOps.grayscale(image) for i in range(0,width): for j in range(0,height): if image.getpixel((i,j)) = 200: image.putpixel((i,j),0) What's the problem with your code? What you're doing is called image binarization, afaik. Thresholding is the basic way to do it, are you unhappy with the results, or the speed of execution? If it is speed, the docs at http://www.pythonware.com/library/pil/handbook/image.htm say you should consider using `getdata' ... What is the general mailing list to ask question on python ? This is one. There is also: http://mail.python.org/mailman/listinfo/baypiggies And http://mail.python.org/mailman/listinfo/python-list -- http://about.me/rosh ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Convert to Black and White to an image
On Fri, Jan 7, 2011 at 11:00 PM, Roshan Mathews rmath...@gmail.com wrote: What is the general mailing list to ask question on python ? This is one. There is also: http://mail.python.org/mailman/listinfo/baypiggies And http://mail.python.org/mailman/listinfo/python-list I dont think baypiggies is the right forum. Would suggest stackoverflow instead. ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Convert to Black and White to an image
On Fri, 2011-01-07 at 22:04 +0530, Narendra Sisodiya wrote: What is the general mailing list to ask question on python ? you are not satisfied with this list? -- regards Kenneth Gonsalves ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Convert to Black and White to an image
On Fri, 2011-01-07 at 23:07 +0530, Venkatraman S wrote: What is the general mailing list to ask question on python ? This is one. There is also: http://mail.python.org/mailman/listinfo/baypiggies And http://mail.python.org/mailman/listinfo/python-list I dont think baypiggies is the right forum. Would suggest stackoverflow instead. I vote for bangpypers -- regards Kenneth Gonsalves ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Convert to Black and White to an image
On Sat, Jan 8, 2011 at 6:55 AM, Kenneth Gonsalves law...@au-kbc.org wrote: On Fri, 2011-01-07 at 22:04 +0530, Narendra Sisodiya wrote: What is the general mailing list to ask question on python ? you are not satisfied with this list? -- regards Kenneth Gonsalves This is not a question of satisfaction. I wanted to know more appropriate mailing list where PIL developer sit and they can help. asking question on wrong mailing list is wrong. Asking the same question on Image-SIG mailing list yield better results. Lots of people replied with excellent answer. http://mail.python.org/pipermail/image-sig/2011-January/006639.html http://mail.python.org/pipermail/image-sig/2011-January/006643.html But I will keep a cc to this mailing list so that people are aware of activities of others too. ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Convert to Black and White to an image
On Sat, Jan 8, 2011 at 9:23 AM, Narendra Sisodiya naren...@narendrasisodiya.com wrote: http://mail.python.org/pipermail/image-sig/2011-January/006639.html So i tried my code snippet and it worked. The above thread asks you to convert to greyscale and then do a pixel check. For a sufficiently big picture(given most of the pictures today are 2-5MB, this is expensive operation. My code snippet, essentially iterates through the pixels in one go and based on the threshhold of each of the RGB values, suitably converts it to B or W. ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Convert to Black and White to an image
On Sat, Jan 8, 2011 at 10:14 AM, Venkatraman S venka...@gmail.com wrote: On Sat, Jan 8, 2011 at 9:23 AM, Narendra Sisodiya naren...@narendrasisodiya.com wrote: http://mail.python.org/pipermail/image-sig/2011-January/006639.html So i tried my code snippet and it worked. I am sorry but your code snippet was less efficient then what i posted initially. moreover, I was having black and white image. However the problem got solved by point method as described in this thread. http://mail.python.org/pipermail/image-sig/2011-January/006641.html The above thread asks you to convert to greyscale and then do a pixel check. For a sufficiently big picture(given most of the pictures today are 2-5MB, this is expensive operation. My code snippet, essentially iterates through the pixels in one go and based on the threshhold of each of the RGB values, suitably converts it to B or W. ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Convert to Black and White to an image
On Sat, Jan 8, 2011 at 10:19 AM, Narendra Sisodiya naren...@narendrasisodiya.com wrote: I am sorry but your code snippet was less efficient then what i posted initially. moreover, I was having black and white image. I thought you needed BW image. (I should read properly!!) Also, can you expatiate on how it was less efficient - i would love to learn. ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Convert to Black and White to an image
On Sat, Jan 8, 2011 at 10:22 AM, Venkatraman S venka...@gmail.com wrote: On Sat, Jan 8, 2011 at 10:19 AM, Narendra Sisodiya naren...@narendrasisodiya.com wrote: I am sorry but your code snippet was less efficient then what i posted initially. moreover, I was having black and white image. I thought you needed BW image. (I should read properly!!) Also, can you expatiate on how it was less efficient - i would love to learn. Yes, I need black and white image, and I was having a grayscale image, I have posted initially this thing. you posted a RBG to black and white algorithm - even if somebody has RBG , why one should use at RBG level, the right way is to do is to convert to grayscale using avalable method. Also, you are using n = image.getpixel((i,j)) if n[0] 127: #R value Which is totally wrong, you are using usiing R value, Any image which has lower R value or just haivng B and G component will be converted into fully black image. you should average or just L = xR+yB+zG method to get a average grayscale value of that pixel. {mainly intensity} Also, I too wrote pixel by pixel method which is expensive and I wanted to know better predefined algorithm. which i got. point method -- ┌─┐ │Narendra Sisodiya │http://narendrasisodiya.com └─┘ ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers