From Chris.Barker at noaa.gov Mon Jan 4 18:42:39 2010 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Mon, 04 Jan 2010 09:42:39 -0800 Subject: [Image-SIG] A possible bug in converting palletized images to QImage In-Reply-To: References: Message-ID: <4B42288F.5080004@noaa.gov> Mauricio Mu?oz Lucero wrote: > I am making an image converter using PIL 1.1.7 and PyQt 4.6 for the gui. > > Everything goes perfect, except when i try to convert an image in "P" > mode (8 bit pixels and using a colour palette) to QImage, using the > ImageQt module. ... > Is it really a bug or am i using incorrectly the ImageQt module? That would be a question for a QT list. But another option is to convert the image form palette to RGB (or RGBA0 with PIL instead. Something like: im = PIL.Image(the_image_file) im = im.convert('RGB') -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov From real.mml at gmail.com Mon Jan 4 20:40:09 2010 From: real.mml at gmail.com (=?ISO-8859-1?Q?Mauricio_Mu=F1oz_Lucero?=) Date: Mon, 4 Jan 2010 20:40:09 +0100 Subject: [Image-SIG] A possible bug in converting palletized images to QImage In-Reply-To: <4B42288F.5080004@noaa.gov> References: <4B42288F.5080004@noaa.gov> Message-ID: 2010/1/4 Christopher Barker wrote: > > Mauricio Mu?oz Lucero wrote: >> >> I am making an image converter using PIL 1.1.7 and PyQt 4.6 for the gui. >> >> Everything goes perfect, except when i try to convert an image in "P" >> mode (8 bit pixels and using a colour palette) to QImage, using the >> ImageQt module. > > ... >> >> Is it really a bug or am i using incorrectly the ImageQt module? > > That would be a question for a QT list. Perhaps i did not explain well the other day, but i think that the problem appears in the ImageQT module of PIL, the piece of code that take charge to convert an image in palette mode to QImage in PIL is: ??????? elif im.mode == "P": ??????????? format = QImage.Format_Indexed8 ??????????? colortable = [] ??????????? palette = im.getpalette() ??????????? for i in range(0, len(palette), 3): ??????????????? colortable.append(rgb(*palette[i:i+3])) But if i change the "palette = im.getpalette()" by: ??????????? palette = im.palette.getdata() ??????????? palette = palette[1] Then i don't get the OverflowError that i commented on my first message, because of that i wrote over a "possible bug" in PIL, with the hope that a developer of PIL could clarify this subject. > But another option is to convert the image form palette to RGB (or RGBA0 with PIL instead. Something like: > > im = PIL.Image(the_image_file) > im = im.convert('RGB') Yes, of course, it's a perfect and elegant solution (if you don't need to manipulate the image in palette mode with QT), only fix the bug could be better. Thanks, Chris! Maurice. From suresh.amritapuri at gmail.com Thu Jan 7 23:35:04 2010 From: suresh.amritapuri at gmail.com (Suresh Kumar) Date: Thu, 7 Jan 2010 14:35:04 -0800 Subject: [Image-SIG] unable to display two images in PIL Message-ID: <61bb29411001071435m202e32ecl520462c8151b32fb@mail.gmail.com> Hi I am using PIL for image processing in ubuntu 9.04. When i give two im.show() commands for two different images, the second image is not displayed (eye of gnome is the display program). It says no such file or directory. Any ideas? thanks suresh -- Even after all this time The sun never says to the earth, "You owe Me." Look what happens with A love like that, It lights the Whole Sky. - Hafiz e Shirazi From suresh.amritapuri at gmail.com Fri Jan 8 21:18:23 2010 From: suresh.amritapuri at gmail.com (Suresh Kumar) Date: Fri, 8 Jan 2010 12:18:23 -0800 Subject: [Image-SIG] PIL show() not working for 2nd pic In-Reply-To: <4f1666381001080529s732a2a53k69474c3bb76eb282@mail.gmail.com> References: <4f1666381001080529s732a2a53k69474c3bb76eb282@mail.gmail.com> Message-ID: <61bb29411001081218q7f273de2v8311571eb40ea946@mail.gmail.com> Hi Thanks for the reply. With one file, it is working correctly. Now I get the following error messages which are different from earlier "file not found ones". (eog:8368): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion `path->depth > 0' failed (eog:8368): Gtk-CRITICAL **: gtk_list_store_get_value: assertion `VALID_ITER (iter, list_store)' failed (eog:8368): GLib-GObject-WARNING **: /build/buildd/glib2.0-2.20.1/gobject/gtype.c:3940: type id `0' is invalid (eog:8368): GLib-GObject-WARNING **: can't peek value table for type `' which is not currently referenced Segmentation fault So any suggestions? my code: ----------------------------------------------------------------------------------------- #!/usr/bin/python print "Aum Amriteshwaryai Namaha" import Image imagePath = "/home/suresh/EE241/book_images_3ed/ch03/" im34 = Image.open(imagePath + "breast_digital_Xray.tif") im35 = Image.open(imagePath + "DFT_no_log.tif") im35.show() def neg(x): return 255-1-x import math def logtr(x): y = math.log(1+x,10) print y return y*100 im34x = im34.point(neg) im34x.show() im35x = im35.point(logtr) im35x.show() ----------------------------------------------end of code-------------------------------- suresh On Fri, Jan 8, 2010 at 5:29 AM, Bram Mertens wrote: > On Fri, Jan 8, 2010 at 1:14 AM, suresh.amritapuri > wrote: >> Hi >> >> I am using PIL for image processing in ubuntu 9.04. When i give two >> im.show() commands for two different images, the second image is not >> displayed (eye of gnome is the display program). It says no such file >> or directory. Any ideas? > > Have you verified that the path to the second image is correct and > that the image is readable by your script? > > e.g. try reversing the order of the images to identify whether or not > it is the image that can not be found or eog. > > Another approach might be to check the file using the os module or > something similar. > > Regards > > Bram > -- R Suresh Kumar, Phd Student, Vislab EE, Univ. of California Riverside, CA 92507 -- Even after all this time The sun never says to the earth, "You owe Me." Look what happens with A love like that, It lights the Whole Sky. - Hafiz e Shirazi From suresh.amritapuri at gmail.com Fri Jan 8 21:49:14 2010 From: suresh.amritapuri at gmail.com (Suresh Kumar) Date: Fri, 8 Jan 2010 12:49:14 -0800 Subject: [Image-SIG] PIL show() not working for 2nd pic In-Reply-To: <41eceb531001081239n503256c0q41ec9a8a63e988a2@mail.gmail.com> References: <4f1666381001080529s732a2a53k69474c3bb76eb282@mail.gmail.com> <61bb29411001081218q7f273de2v8311571eb40ea946@mail.gmail.com> <41eceb531001081239n503256c0q41ec9a8a63e988a2@mail.gmail.com> Message-ID: <61bb29411001081249j459035b2w8e348b35f823242f@mail.gmail.com> Hi, How do you do that? Can you elaborate a bit further? suresh On Fri, Jan 8, 2010 at 12:39 PM, Jerome Leclanche wrote: > I'm pretty sure it's a bug in Eye of Gnome. Have you tried hardcoding > another program in PIL/Image.py ? (_showxv, iirc) > J. Leclanche / Adys > > > On Fri, Jan 8, 2010 at 10:18 PM, Suresh Kumar > wrote: >> >> Hi >> >> Thanks for the reply. >> >> With one file, it is working correctly. Now I get the following error >> messages which are different from earlier "file not found ones". >> >> (eog:8368): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion >> `path->depth > 0' failed >> >> (eog:8368): Gtk-CRITICAL **: gtk_list_store_get_value: assertion >> `VALID_ITER (iter, list_store)' failed >> >> (eog:8368): GLib-GObject-WARNING **: >> /build/buildd/glib2.0-2.20.1/gobject/gtype.c:3940: type id `0' is >> invalid >> >> (eog:8368): GLib-GObject-WARNING **: can't peek value table for type >> `' which is not currently referenced >> Segmentation fault >> >> So any suggestions? >> my code: >> >> ----------------------------------------------------------------------------------------- >> #!/usr/bin/python >> print "Aum Amriteshwaryai Namaha" >> >> import Image >> >> imagePath = "/home/suresh/EE241/book_images_3ed/ch03/" >> >> im34 = Image.open(imagePath + "breast_digital_Xray.tif") >> im35 = Image.open(imagePath + "DFT_no_log.tif") >> im35.show() >> >> def neg(x): >> ? ?return 255-1-x >> >> import math >> >> def logtr(x): >> ? ?y = math.log(1+x,10) >> ? ?print y >> ? ?return y*100 >> >> im34x = im34.point(neg) >> im34x.show() >> >> im35x = im35.point(logtr) >> im35x.show() >> >> ----------------------------------------------end of >> code-------------------------------- >> suresh >> >> >> On Fri, Jan 8, 2010 at 5:29 AM, Bram Mertens >> wrote: >> > On Fri, Jan 8, 2010 at 1:14 AM, suresh.amritapuri >> > wrote: >> >> Hi >> >> >> >> I am using PIL for image processing in ubuntu 9.04. When i give two >> >> im.show() commands for two different images, the second image is not >> >> displayed (eye of gnome is the display program). It says no such file >> >> or directory. Any ideas? >> > >> > Have you verified that the path to the second image is correct and >> > that the image is readable by your script? >> > >> > e.g. try reversing the order of the images to identify whether or not >> > it is the image that can not be found or eog. >> > >> > Another approach might be to check the file using the os module or >> > something similar. >> > >> > Regards >> > >> > Bram >> > >> >> >> >> -- >> R Suresh Kumar, >> Phd Student, Vislab >> EE, Univ. of California >> Riverside, CA 92507 >> -- >> Even after all this time The sun never says to the earth, "You owe Me." >> Look what happens with A love like that, It lights the Whole Sky. >> - Hafiz e Shirazi >> _______________________________________________ >> Image-SIG maillist ?- ?Image-SIG at python.org >> http://mail.python.org/mailman/listinfo/image-sig > > -- R Suresh Kumar, Phd Student, Vislab EE, Univ. of California Riverside, CA 92507 -- Even after all this time The sun never says to the earth, "You owe Me." Look what happens with A love like that, It lights the Whole Sky. - Hafiz e Shirazi From suresh.amritapuri at gmail.com Fri Jan 8 22:08:34 2010 From: suresh.amritapuri at gmail.com (Suresh Kumar) Date: Fri, 8 Jan 2010 13:08:34 -0800 Subject: [Image-SIG] PIL show() not working for 2nd pic In-Reply-To: <41eceb531001081300h7389c160j1509f2cef03afcaa@mail.gmail.com> References: <4f1666381001080529s732a2a53k69474c3bb76eb282@mail.gmail.com> <61bb29411001081218q7f273de2v8311571eb40ea946@mail.gmail.com> <41eceb531001081239n503256c0q41ec9a8a63e988a2@mail.gmail.com> <61bb29411001081249j459035b2w8e348b35f823242f@mail.gmail.com> <41eceb531001081300h7389c160j1509f2cef03afcaa@mail.gmail.com> Message-ID: <61bb29411001081308u9c2fb3ew388fa1fdffae70b6@mail.gmail.com> Hi Thanks. Though not mentioned in the PIL 1.1.6 documentation, I see from (sys.path)/PIL/Image.py that it can be done. But I have just one more qn. Is it possible to modify _showxv() without altering the original code of PIL ? suresh On Fri, Jan 8, 2010 at 1:00 PM, Jerome Leclanche wrote: > In recent versions of PIL you can do img.show(command="display %s") or > something similar (maybe without %s). Otherwise, edit _showxv in > (sys.path)/PIL/Image.py > J. Leclanche / Adys > > > On Fri, Jan 8, 2010 at 10:49 PM, Suresh Kumar > wrote: >> >> Hi, >> >> How do you do that? Can you elaborate a bit further? >> >> suresh >> >> >> On Fri, Jan 8, 2010 at 12:39 PM, Jerome Leclanche >> wrote: >> > I'm pretty sure it's a bug in Eye of Gnome. Have you tried hardcoding >> > another program in PIL/Image.py ? (_showxv, iirc) >> > J. Leclanche / Adys >> > >> > >> > On Fri, Jan 8, 2010 at 10:18 PM, Suresh Kumar >> > >> > wrote: >> >> >> >> Hi >> >> >> >> Thanks for the reply. >> >> >> >> With one file, it is working correctly. Now I get the following error >> >> messages which are different from earlier "file not found ones". >> >> >> >> (eog:8368): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion >> >> `path->depth > 0' failed >> >> >> >> (eog:8368): Gtk-CRITICAL **: gtk_list_store_get_value: assertion >> >> `VALID_ITER (iter, list_store)' failed >> >> >> >> (eog:8368): GLib-GObject-WARNING **: >> >> /build/buildd/glib2.0-2.20.1/gobject/gtype.c:3940: type id `0' is >> >> invalid >> >> >> >> (eog:8368): GLib-GObject-WARNING **: can't peek value table for type >> >> `' which is not currently referenced >> >> Segmentation fault >> >> >> >> So any suggestions? >> >> my code: >> >> >> >> >> >> ----------------------------------------------------------------------------------------- >> >> #!/usr/bin/python >> >> print "Aum Amriteshwaryai Namaha" >> >> >> >> import Image >> >> >> >> imagePath = "/home/suresh/EE241/book_images_3ed/ch03/" >> >> >> >> im34 = Image.open(imagePath + "breast_digital_Xray.tif") >> >> im35 = Image.open(imagePath + "DFT_no_log.tif") >> >> im35.show() >> >> >> >> def neg(x): >> >> ? ?return 255-1-x >> >> >> >> import math >> >> >> >> def logtr(x): >> >> ? ?y = math.log(1+x,10) >> >> ? ?print y >> >> ? ?return y*100 >> >> >> >> im34x = im34.point(neg) >> >> im34x.show() >> >> >> >> im35x = im35.point(logtr) >> >> im35x.show() >> >> >> >> ----------------------------------------------end of >> >> code-------------------------------- >> >> suresh >> >> >> >> >> >> On Fri, Jan 8, 2010 at 5:29 AM, Bram Mertens >> >> wrote: >> >> > On Fri, Jan 8, 2010 at 1:14 AM, suresh.amritapuri >> >> > wrote: >> >> >> Hi >> >> >> >> >> >> I am using PIL for image processing in ubuntu 9.04. When i give two >> >> >> im.show() commands for two different images, the second image is not >> >> >> displayed (eye of gnome is the display program). It says no such >> >> >> file >> >> >> or directory. Any ideas? >> >> > >> >> > Have you verified that the path to the second image is correct and >> >> > that the image is readable by your script? >> >> > >> >> > e.g. try reversing the order of the images to identify whether or not >> >> > it is the image that can not be found or eog. >> >> > >> >> > Another approach might be to check the file using the os module or >> >> > something similar. >> >> > >> >> > Regards >> >> > >> >> > Bram >> >> > >> >> >> >> >> >> >> >> -- >> >> R Suresh Kumar, >> >> Phd Student, Vislab >> >> EE, Univ. of California >> >> Riverside, CA 92507 >> >> -- >> >> Even after all this time The sun never says to the earth, "You owe Me." >> >> Look what happens with A love like that, It lights the Whole Sky. >> >> - Hafiz e Shirazi >> >> _______________________________________________ >> >> Image-SIG maillist ?- ?Image-SIG at python.org >> >> http://mail.python.org/mailman/listinfo/image-sig >> > >> > >> >> >> >> -- >> R Suresh Kumar, >> Phd Student, Vislab >> EE, Univ. of California >> Riverside, CA 92507 >> -- >> Even after all this time The sun never says to the earth, "You owe Me." >> Look what happens with A love like that, It lights the Whole Sky. >> - Hafiz e Shirazi > > -- R Suresh Kumar, Phd Student, Vislab EE, Univ. of California Riverside, CA 92507 -- Even after all this time The sun never says to the earth, "You owe Me." Look what happens with A love like that, It lights the Whole Sky. - Hafiz e Shirazi From suresh.amritapuri at gmail.com Fri Jan 8 22:21:13 2010 From: suresh.amritapuri at gmail.com (Suresh Kumar) Date: Fri, 8 Jan 2010 13:21:13 -0800 Subject: [Image-SIG] PIL show() not working for 2nd pic In-Reply-To: <41eceb531001081315hf4b200ci92b0dcb915082746@mail.gmail.com> References: <4f1666381001080529s732a2a53k69474c3bb76eb282@mail.gmail.com> <61bb29411001081218q7f273de2v8311571eb40ea946@mail.gmail.com> <41eceb531001081239n503256c0q41ec9a8a63e988a2@mail.gmail.com> <61bb29411001081249j459035b2w8e348b35f823242f@mail.gmail.com> <41eceb531001081300h7389c160j1509f2cef03afcaa@mail.gmail.com> <61bb29411001081308u9c2fb3ew388fa1fdffae70b6@mail.gmail.com> <41eceb531001081315hf4b200ci92b0dcb915082746@mail.gmail.com> Message-ID: <61bb29411001081321o36791303u6f3b0df2943acdc4@mail.gmail.com> Thanks. Just now i modified all my show methods to im.show(command="display") and installed ImageMagick package. That temporarily solved my problem. Ok your solution is better anyway. suresh On Fri, Jan 8, 2010 at 1:15 PM, Jerome Leclanche wrote: > You can write a custom show method to your plugins: > def show(self): > path = "/home/adys/.cache/%s.png" % "tmpVfBc3s" > self.save(path) > import os > os.popen("eog %s" % path) > J. Leclanche / Adys > > > On Fri, Jan 8, 2010 at 11:08 PM, Suresh Kumar > wrote: >> >> Hi >> >> Thanks. Though not mentioned in the PIL 1.1.6 documentation, I see >> from (sys.path)/PIL/Image.py that it can be done. But I have just one >> more qn. Is it possible to modify _showxv() without altering the >> original code of PIL ? >> >> suresh >> >> On Fri, Jan 8, 2010 at 1:00 PM, Jerome Leclanche >> wrote: >> > In recent versions of PIL you can do img.show(command="display %s") or >> > something similar (maybe without %s). Otherwise, edit _showxv in >> > (sys.path)/PIL/Image.py >> > J. Leclanche / Adys >> > >> > >> > On Fri, Jan 8, 2010 at 10:49 PM, Suresh Kumar >> > >> > wrote: >> >> >> >> Hi, >> >> >> >> How do you do that? Can you elaborate a bit further? >> >> >> >> suresh >> >> >> >> >> >> On Fri, Jan 8, 2010 at 12:39 PM, Jerome Leclanche >> >> wrote: >> >> > I'm pretty sure it's a bug in Eye of Gnome. Have you tried hardcoding >> >> > another program in PIL/Image.py ? (_showxv, iirc) >> >> > J. Leclanche / Adys >> >> > >> >> > >> >> > On Fri, Jan 8, 2010 at 10:18 PM, Suresh Kumar >> >> > >> >> > wrote: >> >> >> >> >> >> Hi >> >> >> >> >> >> Thanks for the reply. >> >> >> >> >> >> With one file, it is working correctly. Now I get the following >> >> >> error >> >> >> messages which are different from earlier "file not found ones". >> >> >> >> >> >> (eog:8368): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion >> >> >> `path->depth > 0' failed >> >> >> >> >> >> (eog:8368): Gtk-CRITICAL **: gtk_list_store_get_value: assertion >> >> >> `VALID_ITER (iter, list_store)' failed >> >> >> >> >> >> (eog:8368): GLib-GObject-WARNING **: >> >> >> /build/buildd/glib2.0-2.20.1/gobject/gtype.c:3940: type id `0' is >> >> >> invalid >> >> >> >> >> >> (eog:8368): GLib-GObject-WARNING **: can't peek value table for type >> >> >> `' which is not currently referenced >> >> >> Segmentation fault >> >> >> >> >> >> So any suggestions? >> >> >> my code: >> >> >> >> >> >> >> >> >> >> >> >> ----------------------------------------------------------------------------------------- >> >> >> #!/usr/bin/python >> >> >> print "Aum Amriteshwaryai Namaha" >> >> >> >> >> >> import Image >> >> >> >> >> >> imagePath = "/home/suresh/EE241/book_images_3ed/ch03/" >> >> >> >> >> >> im34 = Image.open(imagePath + "breast_digital_Xray.tif") >> >> >> im35 = Image.open(imagePath + "DFT_no_log.tif") >> >> >> im35.show() >> >> >> >> >> >> def neg(x): >> >> >> ? ?return 255-1-x >> >> >> >> >> >> import math >> >> >> >> >> >> def logtr(x): >> >> >> ? ?y = math.log(1+x,10) >> >> >> ? ?print y >> >> >> ? ?return y*100 >> >> >> >> >> >> im34x = im34.point(neg) >> >> >> im34x.show() >> >> >> >> >> >> im35x = im35.point(logtr) >> >> >> im35x.show() >> >> >> >> >> >> ----------------------------------------------end of >> >> >> code-------------------------------- >> >> >> suresh >> >> >> >> >> >> >> >> >> On Fri, Jan 8, 2010 at 5:29 AM, Bram Mertens >> >> >> >> >> >> wrote: >> >> >> > On Fri, Jan 8, 2010 at 1:14 AM, suresh.amritapuri >> >> >> > wrote: >> >> >> >> Hi >> >> >> >> >> >> >> >> I am using PIL for image processing in ubuntu 9.04. When i give >> >> >> >> two >> >> >> >> im.show() commands for two different images, the second image is >> >> >> >> not >> >> >> >> displayed (eye of gnome is the display program). It says no such >> >> >> >> file >> >> >> >> or directory. Any ideas? >> >> >> > >> >> >> > Have you verified that the path to the second image is correct and >> >> >> > that the image is readable by your script? >> >> >> > >> >> >> > e.g. try reversing the order of the images to identify whether or >> >> >> > not >> >> >> > it is the image that can not be found or eog. >> >> >> > >> >> >> > Another approach might be to check the file using the os module or >> >> >> > something similar. >> >> >> > >> >> >> > Regards >> >> >> > >> >> >> > Bram >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> R Suresh Kumar, >> >> >> Phd Student, Vislab >> >> >> EE, Univ. of California >> >> >> Riverside, CA 92507 >> >> >> -- >> >> >> Even after all this time The sun never says to the earth, "You owe >> >> >> Me." >> >> >> Look what happens with A love like that, It lights the Whole Sky. >> >> >> - Hafiz e Shirazi >> >> >> _______________________________________________ >> >> >> Image-SIG maillist ?- ?Image-SIG at python.org >> >> >> http://mail.python.org/mailman/listinfo/image-sig >> >> > >> >> > >> >> >> >> >> >> >> >> -- >> >> R Suresh Kumar, >> >> Phd Student, Vislab >> >> EE, Univ. of California >> >> Riverside, CA 92507 >> >> -- >> >> Even after all this time The sun never says to the earth, "You owe Me." >> >> Look what happens with A love like that, It lights the Whole Sky. >> >> - Hafiz e Shirazi >> > >> > >> >> >> >> -- >> R Suresh Kumar, >> Phd Student, Vislab >> EE, Univ. of California >> Riverside, CA 92507 >> -- >> Even after all this time The sun never says to the earth, "You owe Me." >> Look what happens with A love like that, It lights the Whole Sky. >> - Hafiz e Shirazi > > -- R Suresh Kumar, Phd Student, Vislab EE, Univ. of California Riverside, CA 92507 -- Even after all this time The sun never says to the earth, "You owe Me." Look what happens with A love like that, It lights the Whole Sky. - Hafiz e Shirazi From suresh.amritapuri at gmail.com Fri Jan 8 22:43:54 2010 From: suresh.amritapuri at gmail.com (Suresh Kumar) Date: Fri, 8 Jan 2010 13:43:54 -0800 Subject: [Image-SIG] PIL how to display multiple images side by side Message-ID: <61bb29411001081343y1334d421se8cc434da5a7ff77@mail.gmail.com> Hi, In PIL, how to display multiple images in say m rows and n colums when I have m*n images. suresh -- R Suresh Kumar, Phd Student, Vislab EE, Univ. of California Riverside, CA 92507 -- Even after all this time The sun never says to the earth, "You owe Me." Look what happens with A love like that, It lights the Whole Sky. - Hafiz e Shirazi From adam.pletcher at volition-inc.com Sat Jan 2 18:50:14 2010 From: adam.pletcher at volition-inc.com (Adam Pletcher) Date: Sat, 2 Jan 2010 09:50:14 -0800 Subject: [Image-SIG] Image.show doesn't show image In-Reply-To: <2080055022.4909661262267635579.JavaMail.root@sz0120a.emeryville.ca.mail.comcast.net> References: <533125310.4909191262267473269.JavaMail.root@sz0120a.emeryville.ca.mail.comcast.net> <2080055022.4909661262267635579.JavaMail.root@sz0120a.emeryville.ca.mail.comcast.net> Message-ID: <0106AB904DD7F14EA8FD51A6DA57C30411F2C0@PHXXMBC01.thqinc.com> I believe "show()" simply opens the image file using the associated viewer app for that filetype. For instance, your script successfully displays the image in XNView on my Vista machine. Start by verifying your file associations are correct for that file extension. Try double-clicking that image in Windows explorer, does it open correctly in Windows Photo Gallery? - Adam >From: image-sig-bounces+adam=volition-inc.com at python.org [mailto:image-sig-bounces+adam=volition->inc.com at python.org] On Behalf Of GeorgeFLeCompte at comcast.net >Sent: Thursday, December 31, 2009 7:54 AM >To: image-sig at python.org >Subject: [Image-SIG] Image.show doesn't show image > >I'm running under Microsoft Vista in a pc environment. > >The atached PILTest.py yields a Windows Photo Galery window with no items selected. > >How do I view the image? george This message, including any attachments, may contain privileged and/or confidential information. Any distribution or use of this email by anyone other than the intended recipient(s) is strictly prohibited. If you are not the intended recipient, please notify the sender immediately and delete all copies. Thank you. From cannon.el at gmail.com Mon Jan 4 07:05:58 2010 From: cannon.el at gmail.com (Laura & Edward Cannon) Date: Sun, 3 Jan 2010 22:05:58 -0800 Subject: [Image-SIG] Image.show doesn't show image In-Reply-To: <2080055022.4909661262267635579.JavaMail.root@sz0120a.emeryville.ca.mail.comcast.net> References: <533125310.4909191262267473269.JavaMail.root@sz0120a.emeryville.ca.mail.comcast.net> <2080055022.4909661262267635579.JavaMail.root@sz0120a.emeryville.ca.mail.comcast.net> Message-ID: I have been running vista for some time, and it dosen't seem to work on vista at all. Which version of the library are you running? On Thu, Dec 31, 2009 at 5:53 AM, wrote: > > I'm running under Microsoft Vista in a pc environment. > > > > The atached PILTest.py yields a? Windows Photo Galery window with no items selected. > > > > How do I view the image? > > > > george > > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From jef.mangelschots at gmail.com Tue Jan 5 09:54:03 2010 From: jef.mangelschots at gmail.com (Jef Mangelschots) Date: Tue, 5 Jan 2010 00:54:03 -0800 Subject: [Image-SIG] OpenGL texture images Message-ID: Hi, the PIL handbook I found covers 1.1.5 (no 1.1.6 handbook available yet) It mentions that the ImageGL portion will be in PIL1.1.6 but only for PIL Plus. When I click the PIL Plus link, it says that this library is no longer available. I have installed PIL 1.1.6 for Python 2.6 When I import ImageGL, it complains that it can not find _imaginggl extension module: >>> import ImageGL Traceback (most recent call last): File "", line 1, in File "C:\Python26\lib\site-packages\PIL\ImageGL.py", line 20, in import _imaginggl ImportError: No module named _imaginggl In C:\Python26\lib\site-packages\PIL\ImageGL.py,I read the following comment: # OpenGL pixmap/texture interface (requires imToolkit OpenGL extensions) when I google imToolkit, it can not find that. Can anyone shed some light on the story here. Is it possible to load OpenGL texture images in PIL ? If so, how ? What do I need ? Where can I find imToolkit ? If this function was never completed, what would it take to implement this ? any alternatives ? regards Jef -------------- next part -------------- An HTML attachment was scrubbed... URL: From jef.mangelschots at gmail.com Wed Jan 6 05:03:08 2010 From: jef.mangelschots at gmail.com (Jef Mangelschots) Date: Tue, 5 Jan 2010 20:03:08 -0800 Subject: [Image-SIG] OpenGL texture images In-Reply-To: References: Message-ID: Hi, the PIL handbook I found covers 1.1.5 (no 1.1.6 handbook available yet) It mentions that the ImageGL portion will be in PIL1.1.6 but only for PIL Plus. When I click the PIL Plus link, it says that this library is no longer available. I have installed PIL 1.1.6 for Python 2.6 When I import ImageGL, it complains that it can not find _imaginggl extension module: >>> import ImageGL Traceback (most recent call last): File "", line 1, in File "C:\Python26\lib\site-packages\PIL\ImageGL.py", line 20, in import _imaginggl ImportError: No module named _imaginggl In C:\Python26\lib\site-packages\PIL\ImageGL.py,I read the following comment: # OpenGL pixmap/texture interface (requires imToolkit OpenGL extensions) when I google imToolkit, it can not find that. Can anyone shed some light on the story here. Is it possible to load OpenGL texture images in PIL ? If so, how ? What do I need ? Where can I find imToolkit ? If this function was never completed, what would it take to implement this ? any alternatives ? regards Jef -------------- next part -------------- An HTML attachment was scrubbed... URL: From halbert at halwitz.org Thu Jan 7 23:48:35 2010 From: halbert at halwitz.org (Dan Halbert) Date: Thu, 7 Jan 2010 17:48:35 -0500 (EST) Subject: [Image-SIG] unable to display two images in PIL In-Reply-To: <61bb29411001071435m202e32ecl520462c8151b32fb@mail.gmail.com> References: <61bb29411001071435m202e32ecl520462c8151b32fb@mail.gmail.com> Message-ID: <1262904515.698120471@192.168.2.230> On Thursday, January 7, 2010 5:35pm, "Suresh Kumar" said: > I am using PIL for image processing in ubuntu 9.04. When i give two > im.show() commands for two different images, the second image is not > displayed (eye of gnome is the display program). It says no such file > or directory. Any ideas? This is a bug is due to a modification made to PIL for Debian and Ubuntu. It has to do with eog being clever about reusing its instances, and im.show() deleting a temporary file too soon. I reported this, but nothing has been done about it: https://bugs.launchpad.net/ubuntu/+source/python-imaging/+bug/382987 Fixing the problem is easy, but I haven't had time to figure out the process for submitting a patch to Debian/Ubuntu and having it accepted Dan. -------------- next part -------------- An HTML attachment was scrubbed... URL: From adys.wh at gmail.com Fri Jan 8 21:39:55 2010 From: adys.wh at gmail.com (Jerome Leclanche) Date: Fri, 8 Jan 2010 22:39:55 +0200 Subject: [Image-SIG] PIL show() not working for 2nd pic In-Reply-To: <61bb29411001081218q7f273de2v8311571eb40ea946@mail.gmail.com> References: <4f1666381001080529s732a2a53k69474c3bb76eb282@mail.gmail.com> <61bb29411001081218q7f273de2v8311571eb40ea946@mail.gmail.com> Message-ID: <41eceb531001081239n503256c0q41ec9a8a63e988a2@mail.gmail.com> I'm pretty sure it's a bug in Eye of Gnome. Have you tried hardcoding another program in PIL/Image.py ? (_showxv, iirc) J. Leclanche / Adys On Fri, Jan 8, 2010 at 10:18 PM, Suresh Kumar wrote: > Hi > > Thanks for the reply. > > With one file, it is working correctly. Now I get the following error > messages which are different from earlier "file not found ones". > > (eog:8368): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion > `path->depth > 0' failed > > (eog:8368): Gtk-CRITICAL **: gtk_list_store_get_value: assertion > `VALID_ITER (iter, list_store)' failed > > (eog:8368): GLib-GObject-WARNING **: > /build/buildd/glib2.0-2.20.1/gobject/gtype.c:3940: type id `0' is > invalid > > (eog:8368): GLib-GObject-WARNING **: can't peek value table for type > `' which is not currently referenced > Segmentation fault > > So any suggestions? > my code: > > ----------------------------------------------------------------------------------------- > #!/usr/bin/python > print "Aum Amriteshwaryai Namaha" > > import Image > > imagePath = "/home/suresh/EE241/book_images_3ed/ch03/" > > im34 = Image.open(imagePath + "breast_digital_Xray.tif") > im35 = Image.open(imagePath + "DFT_no_log.tif") > im35.show() > > def neg(x): > return 255-1-x > > import math > > def logtr(x): > y = math.log(1+x,10) > print y > return y*100 > > im34x = im34.point(neg) > im34x.show() > > im35x = im35.point(logtr) > im35x.show() > > ----------------------------------------------end of > code-------------------------------- > suresh > > > On Fri, Jan 8, 2010 at 5:29 AM, Bram Mertens > wrote: > > On Fri, Jan 8, 2010 at 1:14 AM, suresh.amritapuri > > wrote: > >> Hi > >> > >> I am using PIL for image processing in ubuntu 9.04. When i give two > >> im.show() commands for two different images, the second image is not > >> displayed (eye of gnome is the display program). It says no such file > >> or directory. Any ideas? > > > > Have you verified that the path to the second image is correct and > > that the image is readable by your script? > > > > e.g. try reversing the order of the images to identify whether or not > > it is the image that can not be found or eog. > > > > Another approach might be to check the file using the os module or > > something similar. > > > > Regards > > > > Bram > > > > > > -- > R Suresh Kumar, > Phd Student, Vislab > EE, Univ. of California > Riverside, CA 92507 > -- > Even after all this time The sun never says to the earth, "You owe Me." > Look what happens with A love like that, It lights the Whole Sky. > - Hafiz e Shirazi > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From adys.wh at gmail.com Fri Jan 8 22:00:56 2010 From: adys.wh at gmail.com (Jerome Leclanche) Date: Fri, 8 Jan 2010 23:00:56 +0200 Subject: [Image-SIG] PIL show() not working for 2nd pic In-Reply-To: <61bb29411001081249j459035b2w8e348b35f823242f@mail.gmail.com> References: <4f1666381001080529s732a2a53k69474c3bb76eb282@mail.gmail.com> <61bb29411001081218q7f273de2v8311571eb40ea946@mail.gmail.com> <41eceb531001081239n503256c0q41ec9a8a63e988a2@mail.gmail.com> <61bb29411001081249j459035b2w8e348b35f823242f@mail.gmail.com> Message-ID: <41eceb531001081300h7389c160j1509f2cef03afcaa@mail.gmail.com> In recent versions of PIL you can do img.show(command="display %s") or something similar (maybe without %s). Otherwise, edit _showxv in (sys.path)/PIL/Image.py J. Leclanche / Adys On Fri, Jan 8, 2010 at 10:49 PM, Suresh Kumar wrote: > Hi, > > How do you do that? Can you elaborate a bit further? > > suresh > > > On Fri, Jan 8, 2010 at 12:39 PM, Jerome Leclanche > wrote: > > I'm pretty sure it's a bug in Eye of Gnome. Have you tried hardcoding > > another program in PIL/Image.py ? (_showxv, iirc) > > J. Leclanche / Adys > > > > > > On Fri, Jan 8, 2010 at 10:18 PM, Suresh Kumar < > suresh.amritapuri at gmail.com> > > wrote: > >> > >> Hi > >> > >> Thanks for the reply. > >> > >> With one file, it is working correctly. Now I get the following error > >> messages which are different from earlier "file not found ones". > >> > >> (eog:8368): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion > >> `path->depth > 0' failed > >> > >> (eog:8368): Gtk-CRITICAL **: gtk_list_store_get_value: assertion > >> `VALID_ITER (iter, list_store)' failed > >> > >> (eog:8368): GLib-GObject-WARNING **: > >> /build/buildd/glib2.0-2.20.1/gobject/gtype.c:3940: type id `0' is > >> invalid > >> > >> (eog:8368): GLib-GObject-WARNING **: can't peek value table for type > >> `' which is not currently referenced > >> Segmentation fault > >> > >> So any suggestions? > >> my code: > >> > >> > ----------------------------------------------------------------------------------------- > >> #!/usr/bin/python > >> print "Aum Amriteshwaryai Namaha" > >> > >> import Image > >> > >> imagePath = "/home/suresh/EE241/book_images_3ed/ch03/" > >> > >> im34 = Image.open(imagePath + "breast_digital_Xray.tif") > >> im35 = Image.open(imagePath + "DFT_no_log.tif") > >> im35.show() > >> > >> def neg(x): > >> return 255-1-x > >> > >> import math > >> > >> def logtr(x): > >> y = math.log(1+x,10) > >> print y > >> return y*100 > >> > >> im34x = im34.point(neg) > >> im34x.show() > >> > >> im35x = im35.point(logtr) > >> im35x.show() > >> > >> ----------------------------------------------end of > >> code-------------------------------- > >> suresh > >> > >> > >> On Fri, Jan 8, 2010 at 5:29 AM, Bram Mertens > >> wrote: > >> > On Fri, Jan 8, 2010 at 1:14 AM, suresh.amritapuri > >> > wrote: > >> >> Hi > >> >> > >> >> I am using PIL for image processing in ubuntu 9.04. When i give two > >> >> im.show() commands for two different images, the second image is not > >> >> displayed (eye of gnome is the display program). It says no such file > >> >> or directory. Any ideas? > >> > > >> > Have you verified that the path to the second image is correct and > >> > that the image is readable by your script? > >> > > >> > e.g. try reversing the order of the images to identify whether or not > >> > it is the image that can not be found or eog. > >> > > >> > Another approach might be to check the file using the os module or > >> > something similar. > >> > > >> > Regards > >> > > >> > Bram > >> > > >> > >> > >> > >> -- > >> R Suresh Kumar, > >> Phd Student, Vislab > >> EE, Univ. of California > >> Riverside, CA 92507 > >> -- > >> Even after all this time The sun never says to the earth, "You owe Me." > >> Look what happens with A love like that, It lights the Whole Sky. > >> - Hafiz e Shirazi > >> _______________________________________________ > >> Image-SIG maillist - Image-SIG at python.org > >> http://mail.python.org/mailman/listinfo/image-sig > > > > > > > > -- > R Suresh Kumar, > Phd Student, Vislab > EE, Univ. of California > Riverside, CA 92507 > -- > Even after all this time The sun never says to the earth, "You owe Me." > Look what happens with A love like that, It lights the Whole Sky. > - Hafiz e Shirazi > -------------- next part -------------- An HTML attachment was scrubbed... URL: From adys.wh at gmail.com Fri Jan 8 22:15:28 2010 From: adys.wh at gmail.com (Jerome Leclanche) Date: Fri, 8 Jan 2010 23:15:28 +0200 Subject: [Image-SIG] PIL show() not working for 2nd pic In-Reply-To: <61bb29411001081308u9c2fb3ew388fa1fdffae70b6@mail.gmail.com> References: <4f1666381001080529s732a2a53k69474c3bb76eb282@mail.gmail.com> <61bb29411001081218q7f273de2v8311571eb40ea946@mail.gmail.com> <41eceb531001081239n503256c0q41ec9a8a63e988a2@mail.gmail.com> <61bb29411001081249j459035b2w8e348b35f823242f@mail.gmail.com> <41eceb531001081300h7389c160j1509f2cef03afcaa@mail.gmail.com> <61bb29411001081308u9c2fb3ew388fa1fdffae70b6@mail.gmail.com> Message-ID: <41eceb531001081315hf4b200ci92b0dcb915082746@mail.gmail.com> You can write a custom show method to your plugins: def show(self): path = "/home/adys/.cache/%s.png" % "tmpVfBc3s" self.save(path) import os os.popen("eog %s" % path) J. Leclanche / Adys On Fri, Jan 8, 2010 at 11:08 PM, Suresh Kumar wrote: > Hi > > Thanks. Though not mentioned in the PIL 1.1.6 documentation, I see > from (sys.path)/PIL/Image.py that it can be done. But I have just one > more qn. Is it possible to modify _showxv() without altering the > original code of PIL ? > > suresh > > On Fri, Jan 8, 2010 at 1:00 PM, Jerome Leclanche > wrote: > > In recent versions of PIL you can do img.show(command="display %s") or > > something similar (maybe without %s). Otherwise, edit _showxv in > > (sys.path)/PIL/Image.py > > J. Leclanche / Adys > > > > > > On Fri, Jan 8, 2010 at 10:49 PM, Suresh Kumar < > suresh.amritapuri at gmail.com> > > wrote: > >> > >> Hi, > >> > >> How do you do that? Can you elaborate a bit further? > >> > >> suresh > >> > >> > >> On Fri, Jan 8, 2010 at 12:39 PM, Jerome Leclanche > >> wrote: > >> > I'm pretty sure it's a bug in Eye of Gnome. Have you tried hardcoding > >> > another program in PIL/Image.py ? (_showxv, iirc) > >> > J. Leclanche / Adys > >> > > >> > > >> > On Fri, Jan 8, 2010 at 10:18 PM, Suresh Kumar > >> > > >> > wrote: > >> >> > >> >> Hi > >> >> > >> >> Thanks for the reply. > >> >> > >> >> With one file, it is working correctly. Now I get the following error > >> >> messages which are different from earlier "file not found ones". > >> >> > >> >> (eog:8368): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion > >> >> `path->depth > 0' failed > >> >> > >> >> (eog:8368): Gtk-CRITICAL **: gtk_list_store_get_value: assertion > >> >> `VALID_ITER (iter, list_store)' failed > >> >> > >> >> (eog:8368): GLib-GObject-WARNING **: > >> >> /build/buildd/glib2.0-2.20.1/gobject/gtype.c:3940: type id `0' is > >> >> invalid > >> >> > >> >> (eog:8368): GLib-GObject-WARNING **: can't peek value table for type > >> >> `' which is not currently referenced > >> >> Segmentation fault > >> >> > >> >> So any suggestions? > >> >> my code: > >> >> > >> >> > >> >> > ----------------------------------------------------------------------------------------- > >> >> #!/usr/bin/python > >> >> print "Aum Amriteshwaryai Namaha" > >> >> > >> >> import Image > >> >> > >> >> imagePath = "/home/suresh/EE241/book_images_3ed/ch03/" > >> >> > >> >> im34 = Image.open(imagePath + "breast_digital_Xray.tif") > >> >> im35 = Image.open(imagePath + "DFT_no_log.tif") > >> >> im35.show() > >> >> > >> >> def neg(x): > >> >> return 255-1-x > >> >> > >> >> import math > >> >> > >> >> def logtr(x): > >> >> y = math.log(1+x,10) > >> >> print y > >> >> return y*100 > >> >> > >> >> im34x = im34.point(neg) > >> >> im34x.show() > >> >> > >> >> im35x = im35.point(logtr) > >> >> im35x.show() > >> >> > >> >> ----------------------------------------------end of > >> >> code-------------------------------- > >> >> suresh > >> >> > >> >> > >> >> On Fri, Jan 8, 2010 at 5:29 AM, Bram Mertens < > mertensb.mazda at gmail.com> > >> >> wrote: > >> >> > On Fri, Jan 8, 2010 at 1:14 AM, suresh.amritapuri > >> >> > wrote: > >> >> >> Hi > >> >> >> > >> >> >> I am using PIL for image processing in ubuntu 9.04. When i give > two > >> >> >> im.show() commands for two different images, the second image is > not > >> >> >> displayed (eye of gnome is the display program). It says no such > >> >> >> file > >> >> >> or directory. Any ideas? > >> >> > > >> >> > Have you verified that the path to the second image is correct and > >> >> > that the image is readable by your script? > >> >> > > >> >> > e.g. try reversing the order of the images to identify whether or > not > >> >> > it is the image that can not be found or eog. > >> >> > > >> >> > Another approach might be to check the file using the os module or > >> >> > something similar. > >> >> > > >> >> > Regards > >> >> > > >> >> > Bram > >> >> > > >> >> > >> >> > >> >> > >> >> -- > >> >> R Suresh Kumar, > >> >> Phd Student, Vislab > >> >> EE, Univ. of California > >> >> Riverside, CA 92507 > >> >> -- > >> >> Even after all this time The sun never says to the earth, "You owe > Me." > >> >> Look what happens with A love like that, It lights the Whole Sky. > >> >> - Hafiz e Shirazi > >> >> _______________________________________________ > >> >> Image-SIG maillist - Image-SIG at python.org > >> >> http://mail.python.org/mailman/listinfo/image-sig > >> > > >> > > >> > >> > >> > >> -- > >> R Suresh Kumar, > >> Phd Student, Vislab > >> EE, Univ. of California > >> Riverside, CA 92507 > >> -- > >> Even after all this time The sun never says to the earth, "You owe Me." > >> Look what happens with A love like that, It lights the Whole Sky. > >> - Hafiz e Shirazi > > > > > > > > -- > R Suresh Kumar, > Phd Student, Vislab > EE, Univ. of California > Riverside, CA 92507 > -- > Even after all this time The sun never says to the earth, "You owe Me." > Look what happens with A love like that, It lights the Whole Sky. > - Hafiz e Shirazi > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cannon.el at gmail.com Sat Jan 9 00:00:44 2010 From: cannon.el at gmail.com (Edward Cannon) Date: Fri, 8 Jan 2010 15:00:44 -0800 Subject: [Image-SIG] PIL how to display multiple images side by side In-Reply-To: <61bb29411001081343y1334d421se8cc434da5a7ff77@mail.gmail.com> References: <61bb29411001081343y1334d421se8cc434da5a7ff77@mail.gmail.com> Message-ID: <55C8EA39-AA1A-4619-B09E-DCE522A52CD0@gmail.com> Manually make a composite image using the paste() function or simillar and then display that one image. On Jan 8, 2010, at 1:43 PM, Suresh Kumar wrote: > Hi, > > In PIL, how to display multiple images in say m rows and n colums when > I have m*n images. > > suresh > > > -- > R Suresh Kumar, > Phd Student, Vislab > EE, Univ. of California > Riverside, CA 92507 > -- > Even after all this time The sun never says to the earth, "You owe > Me." > Look what happens with A love like that, It lights the Whole Sky. > - Hafiz e Shirazi > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From gregor at kopka.net Sat Jan 9 12:44:57 2010 From: gregor at kopka.net (Gregor Kopka) Date: Sat, 09 Jan 2010 12:44:57 +0100 Subject: [Image-SIG] PIL show() not working for 2nd pic In-Reply-To: <61bb29411001081321o36791303u6f3b0df2943acdc4@mail.gmail.com> References: <4f1666381001080529s732a2a53k69474c3bb76eb282@mail.gmail.com> <61bb29411001081218q7f273de2v8311571eb40ea946@mail.gmail.com> <41eceb531001081239n503256c0q41ec9a8a63e988a2@mail.gmail.com> <61bb29411001081249j459035b2w8e348b35f823242f@mail.gmail.com> <41eceb531001081300h7389c160j1509f2cef03afcaa@mail.gmail.com> <61bb29411001081308u9c2fb3ew388fa1fdffae70b6@mail.gmail.com> <41eceb531001081315hf4b200ci92b0dcb915082746@mail.gmail.com> <61bb29411001081321o36791303u6f3b0df2943acdc4@mail.gmail.com> Message-ID: <4B486C39.9020607@kopka.net> Hello Suresh, under windows image.show() blocks until the external viewer terminates (this is true at least with default installed viewer that comes with XP), after that the temporary file created by PIL will be unlinked. I have no clue if this is true with gnome under Linux, but in case the call to open the external viewer returns immediately (before the viewer has loaded the image) you would see strange things happen since image.show() cleans up the temp file when the python script ends, so you likely run into a race condition: the temp file (created by im35x.show()) gets unlinked before the viewer had time to access it. Always remember: In case you use code whith cleanup functionality (eg. removing temp files on shutdown like image.show() does) keep your code running long enough so the external programs you launched have a chance to access the files you want to hand over to them! My best guess would be that import time time.sleep(10) fixes your issue. Some things i suggest to change in the workaround code from Jermoes: don't hardcode the filename and the location of the temp directory! path = "/home/adys/.cache/%s.png" % "tmpVfBc3s" will probably lead to problems down the road: eg. run two instances of the code in parallel and they'll fight over the temp file, switch to a viewer with a wrapper which immediately returns and you'll potentially overwrite the file again in case you open two viewers in quick succession, transfer the code to a different system where the hardcoded path dosn't exist and the save will fail, (etc.) Better use: def show(self): import os, tempfile path = os.path.join (tempfile.gettempdir(), "%s_%s.png" % (os.getpid(), id(self)) self.save(path) os.popen("eog %s" % path) to avoid the potential problems with hardcoded filenames. Still two things to keep in mind with this: - don't forget that with this introduces a dependency on eye of gnome - don't forget to clean out the directory supplied by tempfile.gettempdir() from time to time to keep the disk from filling up I hope this helps to shed some light on the subject. Regards, Gregor Suresh Kumar schrieb: > Thanks. Just now i modified all my show methods to > im.show(command="display") and installed ImageMagick package. That > temporarily solved my problem. Ok your solution is better anyway. > > suresh > > > On Fri, Jan 8, 2010 at 1:15 PM, Jerome Leclanche wrote: > >> You can write a custom show method to your plugins: >> def show(self): >> path = "/home/adys/.cache/%s.png" % "tmpVfBc3s" >> self.save(path) >> import os >> os.popen("eog %s" % path) >> J. Leclanche / Adys >> >> >> On Fri, Jan 8, 2010 at 11:08 PM, Suresh Kumar >> wrote: >> >>> Hi >>> >>> Thanks. Though not mentioned in the PIL 1.1.6 documentation, I see >>> from (sys.path)/PIL/Image.py that it can be done. But I have just one >>> more qn. Is it possible to modify _showxv() without altering the >>> original code of PIL ? >>> >>> suresh >>> >>> On Fri, Jan 8, 2010 at 1:00 PM, Jerome Leclanche >>> wrote: >>> >>>> In recent versions of PIL you can do img.show(command="display %s") or >>>> something similar (maybe without %s). Otherwise, edit _showxv in >>>> (sys.path)/PIL/Image.py >>>> J. Leclanche / Adys >>>> >>>> >>>> On Fri, Jan 8, 2010 at 10:49 PM, Suresh Kumar >>>> >>>> wrote: >>>> >>>>> Hi, >>>>> >>>>> How do you do that? Can you elaborate a bit further? >>>>> >>>>> suresh >>>>> >>>>> >>>>> On Fri, Jan 8, 2010 at 12:39 PM, Jerome Leclanche >>>>> wrote: >>>>> >>>>>> I'm pretty sure it's a bug in Eye of Gnome. Have you tried hardcoding >>>>>> another program in PIL/Image.py ? (_showxv, iirc) >>>>>> J. Leclanche / Adys >>>>>> >>>>>> >>>>>> On Fri, Jan 8, 2010 at 10:18 PM, Suresh Kumar >>>>>> >>>>>> wrote: >>>>>> >>>>>>> Hi >>>>>>> >>>>>>> Thanks for the reply. >>>>>>> >>>>>>> With one file, it is working correctly. Now I get the following >>>>>>> error >>>>>>> messages which are different from earlier "file not found ones". >>>>>>> >>>>>>> (eog:8368): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion >>>>>>> `path->depth > 0' failed >>>>>>> >>>>>>> (eog:8368): Gtk-CRITICAL **: gtk_list_store_get_value: assertion >>>>>>> `VALID_ITER (iter, list_store)' failed >>>>>>> >>>>>>> (eog:8368): GLib-GObject-WARNING **: >>>>>>> /build/buildd/glib2.0-2.20.1/gobject/gtype.c:3940: type id `0' is >>>>>>> invalid >>>>>>> >>>>>>> (eog:8368): GLib-GObject-WARNING **: can't peek value table for type >>>>>>> `' which is not currently referenced >>>>>>> Segmentation fault >>>>>>> >>>>>>> So any suggestions? >>>>>>> my code: >>>>>>> >>>>>>> >>>>>>> >>>>>>> ----------------------------------------------------------------------------------------- >>>>>>> #!/usr/bin/python >>>>>>> print "Aum Amriteshwaryai Namaha" >>>>>>> >>>>>>> import Image >>>>>>> >>>>>>> imagePath = "/home/suresh/EE241/book_images_3ed/ch03/" >>>>>>> >>>>>>> im34 = Image.open(imagePath + "breast_digital_Xray.tif") >>>>>>> im35 = Image.open(imagePath + "DFT_no_log.tif") >>>>>>> im35.show() >>>>>>> >>>>>>> def neg(x): >>>>>>> return 255-1-x >>>>>>> >>>>>>> import math >>>>>>> >>>>>>> def logtr(x): >>>>>>> y = math.log(1+x,10) >>>>>>> print y >>>>>>> return y*100 >>>>>>> >>>>>>> im34x = im34.point(neg) >>>>>>> im34x.show() >>>>>>> >>>>>>> im35x = im35.point(logtr) >>>>>>> im35x.show() >>>>>>> >>>>>>> ----------------------------------------------end of >>>>>>> code-------------------------------- >>>>>>> suresh >>>>>>> >>>>>>> >>>>>>> On Fri, Jan 8, 2010 at 5:29 AM, Bram Mertens >>>>>>> >>>>>>> wrote: >>>>>>> >>>>>>>> On Fri, Jan 8, 2010 at 1:14 AM, suresh.amritapuri >>>>>>>> wrote: >>>>>>>> >>>>>>>>> Hi >>>>>>>>> >>>>>>>>> I am using PIL for image processing in ubuntu 9.04. When i give >>>>>>>>> two >>>>>>>>> im.show() commands for two different images, the second image is >>>>>>>>> not >>>>>>>>> displayed (eye of gnome is the display program). It says no such >>>>>>>>> file >>>>>>>>> or directory. Any ideas? >>>>>>>>> >>>>>>>> Have you verified that the path to the second image is correct and >>>>>>>> that the image is readable by your script? >>>>>>>> >>>>>>>> e.g. try reversing the order of the images to identify whether or >>>>>>>> not >>>>>>>> it is the image that can not be found or eog. >>>>>>>> >>>>>>>> Another approach might be to check the file using the os module or >>>>>>>> something similar. >>>>>>>> >>>>>>>> Regards >>>>>>>> >>>>>>>> Bram >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> -- >>>>>>> R Suresh Kumar, >>>>>>> Phd Student, Vislab >>>>>>> EE, Univ. of California >>>>>>> Riverside, CA 92507 >>>>>>> -- >>>>>>> Even after all this time The sun never says to the earth, "You owe >>>>>>> Me." >>>>>>> Look what happens with A love like that, It lights the Whole Sky. >>>>>>> - Hafiz e Shirazi >>>>>>> _______________________________________________ >>>>>>> Image-SIG maillist - Image-SIG at python.org >>>>>>> http://mail.python.org/mailman/listinfo/image-sig >>>>>>> >>>>>> >>>>> >>>>> -- >>>>> R Suresh Kumar, >>>>> Phd Student, Vislab >>>>> EE, Univ. of California >>>>> Riverside, CA 92507 >>>>> -- >>>>> Even after all this time The sun never says to the earth, "You owe Me." >>>>> Look what happens with A love like that, It lights the Whole Sky. >>>>> - Hafiz e Shirazi >>>>> >>>> >>> >>> -- >>> R Suresh Kumar, >>> Phd Student, Vislab >>> EE, Univ. of California >>> Riverside, CA 92507 >>> -- >>> Even after all this time The sun never says to the earth, "You owe Me." >>> Look what happens with A love like that, It lights the Whole Sky. >>> - Hafiz e Shirazi >>> >> > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: gregor.vcf Type: text/x-vcard Size: 314 bytes Desc: not available URL: From adminkoff at cox.net Mon Jan 11 08:08:18 2010 From: adminkoff at cox.net (Anthony D. Minkoff) Date: Mon, 11 Jan 2010 00:08:18 -0700 Subject: [Image-SIG] PIL for Python 3 Message-ID: Is PIL going to be developed for Python 3, or is it Python 2 only for the foreseeable future? From janssen at parc.com Mon Jan 11 18:18:02 2010 From: janssen at parc.com (Bill Janssen) Date: Mon, 11 Jan 2010 09:18:02 PST Subject: [Image-SIG] dithering on Image.convert() from "RGB" to "P" Message-ID: <209.1263230282@parc.com> I was just looking into why error diffusion was occurring in my images when I went from RGB to P with a 140-color image. Unexpected. I see in the code that Floyd-Steinberg error diffusion will be applied on conversions from "RGB" to "P", regardless of whether it's needed, unless the optional "dither" parameter is specified. So I changed my code to specify "dither=Image.NONE" where appropriate. Would it make sense to modify that default behavior to dither only if needed? That is, when converting from "RGB" to "P", only dither if the number of colors is greater than 256? Bill From joris.vankerschaver at gmail.com Sun Jan 17 13:54:05 2010 From: joris.vankerschaver at gmail.com (Joris Vankerschaver) Date: Sun, 17 Jan 2010 13:54:05 +0100 Subject: [Image-SIG] Korean/unicode strings in PIL Message-ID: <4B53086D.3010109@gmail.com> Dear all, I would like to use PIL to generate thumbnails with Korean characters. Unfortunately, the code that I use doesn't produce the correct output. Here is a small snippet, based on some PIL example code. code = u'\uAC00' letter = code.encode('UTF-8') i = Image.new("RGB", (25,25)) d = ImageDraw.Draw(i) f = ImageFont.truetype("AppleMyungjo.ttf", 12, encoding = "unic") d.text((0,0), letter, font = f) i.save(open("ga.png", "wb"), "PNG") Here, "AppleMyungjo.ttf" is a font that has some Korean characters in it. The program doesn't produce any errors, but the output image just contains garbage pixels (different ones based on the font I pick, but never the correct ones). I've tried playing with the different options, but to no avail. To see what the output should look like, simply do "print u'\uAC00'.encode('UTF-8')". Does anyone have some sample code to produce Korean/Japanese/Chinese/random unicode text in images? I'm afraid this might be a trivial problem, but the obvious google searches didn't yield anything useful. Thanks a lot, Joris Vankerschaver. From sierra_mtnview at sbcglobal.net Sun Jan 17 17:16:38 2010 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Sun, 17 Jan 2010 08:16:38 -0800 Subject: [Image-SIG] Printing Matplotlib (MPL) Graphs in PIL? Message-ID: <4B5337E6.2020901@sbcglobal.net> I've used MPL a bit, and am wondering if there's a facility in PIL for sending graphic images to a printer, or putting them in some format like png? I don't necessarily want the graphics to appear in a window, but would like to print them directly once they are ready. Can one put in a page feed, so that images don't all fall on the same page or cut across pages? I asked about this in the MPL list and didn't get a single reply, so I guess there's nothing in MPL that will do it. -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet "I was thinking about how people seem to read the Bible a whole lot more as they get older; then it dawned on me . . they're cramming for their final exam." -- George Carlin Web Page: From fetchinson at googlemail.com Mon Jan 11 11:09:34 2010 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Mon, 11 Jan 2010 11:09:34 +0100 Subject: [Image-SIG] PIL for Python 3 In-Reply-To: References: Message-ID: > Is PIL going to be developed for Python 3, or is it Python 2 only for the > foreseeable future? If you are feeling lucky http://www.google.com/search?q=pil+python+3 will bring you to http://effbot.org/zone/pil-index.htm HTH, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From suresh.amritapuri at gmail.com Mon Jan 11 21:24:58 2010 From: suresh.amritapuri at gmail.com (Suresh Kumar) Date: Mon, 11 Jan 2010 12:24:58 -0800 Subject: [Image-SIG] PIL show() not working for 2nd pic In-Reply-To: <4B486C39.9020607@kopka.net> References: <4f1666381001080529s732a2a53k69474c3bb76eb282@mail.gmail.com> <61bb29411001081218q7f273de2v8311571eb40ea946@mail.gmail.com> <41eceb531001081239n503256c0q41ec9a8a63e988a2@mail.gmail.com> <61bb29411001081249j459035b2w8e348b35f823242f@mail.gmail.com> <41eceb531001081300h7389c160j1509f2cef03afcaa@mail.gmail.com> <61bb29411001081308u9c2fb3ew388fa1fdffae70b6@mail.gmail.com> <41eceb531001081315hf4b200ci92b0dcb915082746@mail.gmail.com> <61bb29411001081321o36791303u6f3b0df2943acdc4@mail.gmail.com> <4B486C39.9020607@kopka.net> Message-ID: <61bb29411001111224r324f2fedm9f6db512fd694046@mail.gmail.com> thanks Gregor, Thank you so much for your time. As I wrote earlier, I temporarily managed the problem by using ImageMagick display. regards suresh On Sat, Jan 9, 2010 at 3:44 AM, Gregor Kopka wrote: > Hello Suresh, > > under windows image.show() blocks until the external viewer terminates > (this is true at least with default installed viewer that comes with XP), > after that the temporary file created by PIL will be unlinked. > > I have no clue if this is true with gnome under Linux, but in case the call > to open the external viewer returns immediately (before the viewer has > loaded the image) you would see strange things happen since image.show() > cleans up the temp file when the python script ends, so you likely run into > a race condition: the temp file (created by im35x.show()) gets unlinked > before the viewer had time to access it. > > Always remember: In case you use code whith cleanup functionality (eg. > removing temp files on shutdown like image.show() does) keep your code > running long enough so the external programs you launched have a chance to > access the files you want to hand over to them! > > My best guess would be that > > import time > time.sleep(10) > > fixes your issue. > > Some things i suggest to change in the workaround code from Jermoes: don't > hardcode the filename and the location of the temp directory! > > path = "/home/adys/.cache/%s.png" % "tmpVfBc3s" > > will probably lead to problems down the road: eg. run two instances of the > code in parallel and they'll fight over the temp file, switch to a viewer > with a wrapper which immediately returns and you'll potentially overwrite > the file again in case you open two viewers in quick succession, transfer > the code to a different system where the hardcoded path dosn't exist and the > save will fail, (etc.) > > Better use: > > def show(self): > import os, tempfile > path = os.path.join (tempfile.gettempdir(), "%s_%s.png" % (os.getpid(), id(self)) > self.save(path) > os.popen("eog %s" % path) > > to avoid the potential problems with hardcoded filenames. > > Still two things to keep in mind with this: > - don't forget that with this introduces a dependency on eye of gnome > - don't forget to clean out the directory supplied by tempfile.gettempdir() > from time to time to keep the disk from filling up > > I hope this helps to shed some light on the subject. > > Regards, > > Gregor > > Suresh Kumar schrieb: > > Thanks. Just now i modified all my show methods to > im.show(command="display") and installed ImageMagick package. That > temporarily solved my problem. Ok your solution is better anyway. > > suresh > > > On Fri, Jan 8, 2010 at 1:15 PM, Jerome Leclanche wrote: > > > You can write a custom show method to your plugins: > def show(self): > path = "/home/adys/.cache/%s.png" % "tmpVfBc3s" > self.save(path) > import os > os.popen("eog %s" % path) > J. Leclanche / Adys > > > On Fri, Jan 8, 2010 at 11:08 PM, Suresh Kumar > wrote: > > > Hi > > Thanks. Though not mentioned in the PIL 1.1.6 documentation, I see > from (sys.path)/PIL/Image.py that it can be done. But I have just one > more qn. Is it possible to modify _showxv() without altering the > original code of PIL ? > > suresh > > On Fri, Jan 8, 2010 at 1:00 PM, Jerome Leclanche > wrote: > > > In recent versions of PIL you can do img.show(command="display %s") or > something similar (maybe without %s). Otherwise, edit _showxv in > (sys.path)/PIL/Image.py > J. Leclanche / Adys > > > On Fri, Jan 8, 2010 at 10:49 PM, Suresh Kumar > wrote: > > > Hi, > > How do you do that? Can you elaborate a bit further? > > suresh > > > On Fri, Jan 8, 2010 at 12:39 PM, Jerome Leclanche > wrote: > > > I'm pretty sure it's a bug in Eye of Gnome. Have you tried hardcoding > another program in PIL/Image.py ? (_showxv, iirc) > J. Leclanche / Adys > > > On Fri, Jan 8, 2010 at 10:18 PM, Suresh Kumar > wrote: > > > Hi > > Thanks for the reply. > > With one file, it is working correctly. Now I get the following > error > messages which are different from earlier "file not found ones". > > (eog:8368): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion > `path->depth > 0' failed > > (eog:8368): Gtk-CRITICAL **: gtk_list_store_get_value: assertion > `VALID_ITER (iter, list_store)' failed > > (eog:8368): GLib-GObject-WARNING **: > /build/buildd/glib2.0-2.20.1/gobject/gtype.c:3940: type id `0' is > invalid > > (eog:8368): GLib-GObject-WARNING **: can't peek value table for type > `' which is not currently referenced > Segmentation fault > > So any suggestions? > my code: > > > > ----------------------------------------------------------------------------------------- > #!/usr/bin/python > print "Aum Amriteshwaryai Namaha" > > import Image > > imagePath = "/home/suresh/EE241/book_images_3ed/ch03/" > > im34 = Image.open(imagePath + "breast_digital_Xray.tif") > im35 = Image.open(imagePath + "DFT_no_log.tif") > im35.show() > > def neg(x): > return 255-1-x > > import math > > def logtr(x): > y = math.log(1+x,10) > print y > return y*100 > > im34x = im34.point(neg) > im34x.show() > > im35x = im35.point(logtr) > im35x.show() > > ----------------------------------------------end of > code-------------------------------- > suresh > > > On Fri, Jan 8, 2010 at 5:29 AM, Bram Mertens > wrote: > > > On Fri, Jan 8, 2010 at 1:14 AM, suresh.amritapuri wrote: > > > Hi > > I am using PIL for image processing in ubuntu 9.04. When i give > two > im.show() commands for two different images, the second image is > not > displayed (eye of gnome is the display program). It says no such > file > or directory. Any ideas? > > > Have you verified that the path to the second image is correct and > that the image is readable by your script? > > e.g. try reversing the order of the images to identify whether or > not > it is the image that can not be found or eog. > > Another approach might be to check the file using the os module or > something similar. > > Regards > > Bram > > > > -- > R Suresh Kumar, > Phd Student, Vislab > EE, Univ. of California > Riverside, CA 92507 > -- > Even after all this time The sun never says to the earth, "You owe > Me." > Look what happens with A love like that, It lights the Whole Sky. > - Hafiz e Shirazi > _______________________________________________ > Image-SIG maillist - Image-SIG at python.orghttp://mail.python.org/mailman/listinfo/image-sig > > -- > R Suresh Kumar, > Phd Student, Vislab > EE, Univ. of California > Riverside, CA 92507 > -- > Even after all this time The sun never says to the earth, "You owe Me." > Look what happens with A love like that, It lights the Whole Sky. > - Hafiz e Shirazi > > > -- > R Suresh Kumar, > Phd Student, Vislab > EE, Univ. of California > Riverside, CA 92507 > -- > Even after all this time The sun never says to the earth, "You owe Me." > Look what happens with A love like that, It lights the Whole Sky. > - Hafiz e Shirazi > > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > -- R Suresh Kumar, Phd Student, Vislab EE, Univ. of California Riverside, CA 92507 -- Even after all this time The sun never says to the earth, "You owe Me." Look what happens with A love like that, It lights the Whole Sky. - Hafiz e Shirazi -------------- next part -------------- An HTML attachment was scrubbed... URL: From suresh.amritapuri at gmail.com Mon Jan 11 21:26:47 2010 From: suresh.amritapuri at gmail.com (Suresh Kumar) Date: Mon, 11 Jan 2010 12:26:47 -0800 Subject: [Image-SIG] PIL how to display multiple images side by side In-Reply-To: <55C8EA39-AA1A-4619-B09E-DCE522A52CD0@gmail.com> References: <61bb29411001081343y1334d421se8cc434da5a7ff77@mail.gmail.com> <55C8EA39-AA1A-4619-B09E-DCE522A52CD0@gmail.com> Message-ID: <61bb29411001111226g207b8a95te4f9cccd33655205@mail.gmail.com> Is there any way I can force the images to stay? the following is the code that I have adapted from somewhere for this purpose. Thanks suresh ----------------beginning of code-------------------- def button_click_exit_mainloop (event): event.widget.quit() # this will cause mainloop to unblock. root = Tkinter.Tk() root.bind("