Top-rated Python recipes tagged "graphics"http://code.activestate.com/recipes/langs/python/tags/graphics/top/2016-09-25T21:24:12-07:00ActiveState Code RecipesWatermark with PIL (Python) 2005-01-12T11:07:01-08:00Shane Hathawayhttp://code.activestate.com/recipes/users/2257010/http://code.activestate.com/recipes/362879-watermark-with-pil/ <p style="color: grey"> Python recipe 362879 by <a href="/recipes/users/2257010/">Shane Hathaway</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>Apply a watermark to an image using the Python Imaging Library. Supports color, tiling, scaling, and opacity reduction.</p> Povray for python (Python) 2003-06-13T21:22:18-07:00Simon Burtonhttp://code.activestate.com/recipes/users/860809/http://code.activestate.com/recipes/205451-povray-for-python/ <p style="color: grey"> Python recipe 205451 by <a href="/recipes/users/860809/">Simon Burton</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>Here is a relatively simple framework for making povray files from your favourite programming language, python. It's good for creating structured/mathematical scenes and animations.</p> pack multiple images of different sizes into one image (Python) 2005-10-16T22:33:06-07:00S Whttp://code.activestate.com/recipes/users/1759688/http://code.activestate.com/recipes/442299-pack-multiple-images-of-different-sizes-into-one-i/ <p style="color: grey"> Python recipe 442299 by <a href="/recipes/users/1759688/">S W</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>Packing images of different sizes into one image is often required in order to efficiently use hardware accelerated texture mapping functions of 3D video cards.</p> Use PIL to make a "contact sheet" montage of images (Python) 2005-05-02T15:28:49-07:00Rick Mullerhttp://code.activestate.com/recipes/users/1461790/http://code.activestate.com/recipes/412982-use-pil-to-make-a-contact-sheet-montage-of-images/ <p style="color: grey"> Python recipe 412982 by <a href="/recipes/users/1461790/">Rick Muller</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>The Python Imaging Library (PIL) makes many tasks easy in digital photography. This recipe shows how to make a "contact sheet" of images, a single image with thumbnails of many different pictures. It's limited in that it will only work with pictures of the same shape, but you can make some really fun images.</p> Mandelbrot fractal using PIL (Python) 2010-03-26T04:39:46-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577111-mandelbrot-fractal-using-pil/ <p style="color: grey"> Python recipe 577111 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>). Revision 2. </p> <p>Mandelbrot fractal using Python Image Library (PIL).</p> Change the wallpaper under Windows (Python) 2005-07-01T02:37:03-07:00Sébastien Sauvagehttp://code.activestate.com/recipes/users/2503505/http://code.activestate.com/recipes/435877-change-the-wallpaper-under-windows/ <p style="color: grey"> Python recipe 435877 by <a href="/recipes/users/2503505/">Sébastien Sauvage</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>Change the current wallpaper under Windows</p> EAN Bar code image generator (Python) 2005-06-18T04:07:13-07:00remi inconnuhttp://code.activestate.com/recipes/users/832244/http://code.activestate.com/recipes/426069-ean-bar-code-image-generator/ <p style="color: grey"> Python recipe 426069 by <a href="/recipes/users/832244/">remi inconnu</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>This class generate EAN bar code, it required PIL (python imaging library) installed.</p> <p>If the code has not checksum (12 digits), it added automatically.</p> <p>Create bar code sample : from EANBarCode import EanBarCode bar = EanBarCode() bar.getImage("9782212110708",50,"gif")</p> Display an Image from a specified file (Python) 2003-10-08T01:54:55-07:00Simon Peveretthttp://code.activestate.com/recipes/users/1410328/http://code.activestate.com/recipes/227575-display-an-image-from-a-specified-file/ <p style="color: grey"> Python recipe 227575 by <a href="/recipes/users/1410328/">Simon Peverett</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>Reads an image file from the filename specified as the 1st parameter on the command line and displays it on screen. Uses the PIL module so that it can load almost any image file type supported by that module and uses Tkinter to display the image on a Tkinter canvas.</p> <p>I'm new to Python so excuse the clunkyness of implementation.</p> Quasicrystal Pattern Generator (Python) 2015-08-08T20:50:23-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/579094-quasicrystal-pattern-generator/ <p style="color: grey"> Python recipe 579094 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>). </p> <p>Quasicrystal Pattern Generator</p> Python Mandelbrot Fractal with Tkinter (Python) 2015-05-06T09:57:27-07:00Antoni Gualhttp://code.activestate.com/recipes/users/4182514/http://code.activestate.com/recipes/579048-python-mandelbrot-fractal-with-tkinter/ <p style="color: grey"> Python recipe 579048 by <a href="/recipes/users/4182514/">Antoni Gual</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). Revision 9. </p> <p>Displays in a Tk window a pretty coloured 640x480 Mandelbrot set in 6 seconds. Calculates each one of the 300K pixels with a maximum of 256 iterations. <br> Only Tkinter used. Tested with Python 3.4 <br> I will test any contribution and add it to the code if worthy.</p> Bilinear Interpolation (Python) 2013-02-23T04:00:52-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578469-bilinear-interpolation/ <p style="color: grey"> Python recipe 578469 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/pil/">pil</a>). </p> <p>Creates a surface from a grid of random numbers using Bilinear Interpolation.</p> Bezier Curve using De Casteljau algorithm (Python) 2011-11-25T02:33:54-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577961-bezier-curve-using-de-casteljau-algorithm/ <p style="color: grey"> Python recipe 577961 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>). </p> <p>Draws a random Bezier Curve using De Casteljau algorithm.</p> Multi-threaded Mandelbrot Fractal (Python) 2011-05-01T17:33:20-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577680-multi-threaded-mandelbrot-fractal/ <p style="color: grey"> Python recipe 577680 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/thread/">thread</a>, <a href="/recipes/tags/threading/">threading</a>, <a href="/recipes/tags/threads/">threads</a>). Revision 3. </p> <p>Multi-threaded Mandelbrot Fractal.</p> Download satellite images from NASA's site (Python) 2006-08-24T07:07:56-07:00Sergei Vavilovhttp://code.activestate.com/recipes/users/2974619/http://code.activestate.com/recipes/496966-download-satellite-images-from-nasas-site/ <p style="color: grey"> Python recipe 496966 by <a href="/recipes/users/2974619/">Sergei Vavilov</a> (<a href="/recipes/tags/graphics/">graphics</a>). Revision 2. </p> <p>This script downloads satellite image of desired position (in degrees) from the NASA's OnEarth site (<a href="http://onearth.jpl.nasa.gov/%29." rel="nofollow">http://onearth.jpl.nasa.gov/).</a></p> A Sinus Plasma, using Pygame (Python) 2004-11-07T23:38:22-08:00S Whttp://code.activestate.com/recipes/users/1759688/http://code.activestate.com/recipes/334696-a-sinus-plasma-using-pygame/ <p style="color: grey"> Python recipe 334696 by <a href="/recipes/users/1759688/">S W</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>An old-school demo effect, using sine wave interference patterns. Entertaining for at least a few minutes :)</p> <p>Modify the freq variable for different patterns.</p> Convert Image Format (Python) 2003-02-16T02:10:03-08:00Doug Blandinghttp://code.activestate.com/recipes/users/984954/http://code.activestate.com/recipes/180801-convert-image-format/ <p style="color: grey"> Python recipe 180801 by <a href="/recipes/users/984954/">Doug Blanding</a> (<a href="/recipes/tags/graphics/">graphics</a>). Revision 4. </p> <p>Simple GUI to allow converting images from one format to another. Available formats are: .gif .jpg .png .tif .bmp Uses PIL.</p> colormap: Returns an RGB tuple on a 0 to 255 scale for graphical packages (Python) 2005-04-20T12:46:35-07:00Alexander Pletzerhttp://code.activestate.com/recipes/users/98107/http://code.activestate.com/recipes/52273-colormap-returns-an-rgb-tuple-on-a-0-to-255-scale-/ <p style="color: grey"> Python recipe 52273 by <a href="/recipes/users/98107/">Alexander Pletzer</a> (<a href="/recipes/tags/graphics/">graphics</a>). Revision 5. </p> <p>These functions, when given a magnitude 'mag' between cmin and cmax, return a colour tuple (red, green, blue) on a 0 to 255 scale. The tuple can consist of strings (strRgb) as required in Tk calls, or integers (rgb) as required in Java applications.</p> Image to ASCII Art Converter (Python) 2016-09-25T21:24:12-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/580702-image-to-ascii-art-converter/ <p style="color: grey"> Python recipe 580702 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/pil/">pil</a>). </p> <p>ASCII Art Generator (Image to ASCII Art Converter)</p> <p>Input file maybe JPG, PNG, GIF etc. Output file name maybe output.txt etc.</p> Image Projection Onto Sphere (Python) 2016-07-31T22:50:28-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/580695-image-projection-onto-sphere/ <p style="color: grey"> Python recipe 580695 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/image_processing/">image_processing</a>, <a href="/recipes/tags/imaging/">imaging</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/pil/">pil</a>). </p> <p>Image projection onto sphere using Equirectangular map projection.</p> <p>Download the test image from the Wikipedia page!</p> Random Maze Generator (Python) 2012-12-14T09:09:22-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578356-random-maze-generator/ <p style="color: grey"> Python recipe 578356 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/ai/">ai</a>, <a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/pil/">pil</a>). Revision 2. </p> <p>Random maze generator using depth-first search.</p> <p>It starts the maze path from a random cell and there is no exit defined but actually any 2 cells on the path (white cells) can be assigned to be entry and exit locations. (I could just add code to randomly select 2 white cells and change their colors to something else but I thought it looks better this way.)</p>