Popular recipes tagged "image"http://code.activestate.com/recipes/tags/image/2017-04-10T21:14:36-07:00ActiveState Code RecipesMetro Spinner for Tkinter (Python)
2017-04-10T21:14:36-07:00Miguel Martínez Lópezhttp://code.activestate.com/recipes/users/4189907/http://code.activestate.com/recipes/580777-metro-spinner-for-tkinter/
<p style="color: grey">
Python
recipe 580777
by <a href="/recipes/users/4189907/">Miguel Martínez López</a>
(<a href="/recipes/tags/canvas/">canvas</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/pil/">pil</a>, <a href="/recipes/tags/rotation/">rotation</a>, <a href="/recipes/tags/spinner/">spinner</a>, <a href="/recipes/tags/tkinter/">tkinter</a>).
</p>
<p>I create a rotating image class <em>RotatingIcon</em> inspired and based on this code:</p>
<p><a href="http://stackoverflow.com/questions/15736530/python-tkinter-rotate-image-animation" rel="nofollow">http://stackoverflow.com/questions/15736530/python-tkinter-rotate-image-animation</a></p>
<p>Features:</p>
<ul>
<li>Methods to stop and start the animation</li>
<li>The animation automically stops when the window is not mapped, and the animation continues when the window is mapped again</li>
<li>Time setting to control the speed of the animation</li>
<li>All the formats accepted for PIL could be used. XBM format is automatically converted to Tk Bitmap. The advantage of Bitmats is the possibility to change the color of the foreground.</li>
</ul>
<p>I added 6 different styles of spinners with different sizes.</p>
<p>I used fontawesome.io for the icon generation.</p>
<p>For more metro widgets see here:</p>
<p><a href="https://code.activestate.com/recipes/580729-metro-ui-tkinter/" rel="nofollow">https://code.activestate.com/recipes/580729-metro-ui-tkinter/</a></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>
Saving a numpy array to png image using fitz / MuPDF (PyMuPDF) (Python)
2016-03-19T12:57:38-07:00Harald Liederhttp://code.activestate.com/recipes/users/4191581/http://code.activestate.com/recipes/580630-saving-a-numpy-array-to-png-image-using-fitz-mupdf/
<p style="color: grey">
Python
recipe 580630
by <a href="/recipes/users/4191581/">Harald Lieder</a>
(<a href="/recipes/tags/fitz/">fitz</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/mupdf/">mupdf</a>, <a href="/recipes/tags/numpy/">numpy</a>, <a href="/recipes/tags/png/">png</a>, <a href="/recipes/tags/pymupdf/">pymupdf</a>).
Revision 2.
</p>
<p>If a pixel array is defined in numpy, it can be saved as a PNG image VERY fast if you use PyMuPDF.</p>
Image Resizer (Python)
2016-05-22T16:45:52-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/580663-image-resizer/
<p style="color: grey">
Python
recipe 580663
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/utilities/">utilities</a>, <a href="/recipes/tags/utility/">utility</a>).
Revision 2.
</p>
<p>Image resizer/converter command-line utility.</p>
Random Planet Generator Using Plasma Fractal (Python)
2016-01-25T23:05:25-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/580495-random-planet-generator-using-plasma-fractal/
<p style="color: grey">
Python
recipe 580495
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>Random Planet Generator using 3D Plasma Fractal and Voxel-based Ray Tracing for rendering.</p>
<p>Instead of generating 2D Plasma Fractal and projecting onto sphere, it generates 3D Plasma Fractal (cube) and cuts sphere from it.</p>
Reaction Diffusion Simulation (Python)
2015-10-16T19:52:02-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/579114-reaction-diffusion-simulation/
<p style="color: grey">
Python
recipe 579114
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/chaos/">chaos</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>, <a href="/recipes/tags/physics/">physics</a>, <a href="/recipes/tags/simulation/">simulation</a>).
Revision 2.
</p>
<p>Reaction-Diffusion Simulation using Gray-Scott Model.</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>
2D Discrete Fourier Transform (Python)
2015-01-03T03:39:34-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578997-2d-discrete-fourier-transform/
<p style="color: grey">
Python
recipe 578997
by <a href="/recipes/users/4172570/">FB36</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/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/signal_processing/">signal_processing</a>).
</p>
<p>2D Discrete Fourier Transform (DFT) and its inverse.</p>
<p>Calculates 2D DFT of an image and recreates the image using inverse 2D DFT.</p>
<p>Computation is slow so only suitable for thumbnail size images.</p>
Draw Text To Image (Python)
2015-07-13T18:04:30-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/579013-draw-text-to-image/
<p style="color: grey">
Python
recipe 579013
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/pil/">pil</a>).
Revision 2.
</p>
<p>PIL does not allow resizing default bitmap font.
This code resizes it by itself.</p>
<p>The disadvantage is slow speed but the advantage is it becomes possible to set color of each pixel of text foreground and background.</p>
<p>As an example I set foreground to reverse colors and background to grayscale.</p>
Mandelbrot Fractal image output to ppm file (Python)
2015-01-17T19:21:47-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/579006-mandelbrot-fractal-image-output-to-ppm-file/
<p style="color: grey">
Python
recipe 579006
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/fractal/">fractal</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>It creates image output without using any external library.</p>
<p>PPM image files can be viewed and converted to other image file formats using many applications, GIMP or IrfanView for example.</p>
Image Converter (Python)
2015-01-18T19:14:38-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/579007-image-converter/
<p style="color: grey">
Python
recipe 579007
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/conversion/">conversion</a>, <a href="/recipes/tags/conversions/">conversions</a>, <a href="/recipes/tags/convert/">convert</a>, <a href="/recipes/tags/converter/">converter</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/pil/">pil</a>).
</p>
<p>Converts an image from one format to another using PIL.</p>
Sort images from different sources by picture taken date (Exif) (Python)
2013-09-24T12:43:31-07:00Rutger Saalminkhttp://code.activestate.com/recipes/users/4187940/http://code.activestate.com/recipes/578672-sort-images-from-different-sources-by-picture-take/
<p style="color: grey">
Python
recipe 578672
by <a href="/recipes/users/4187940/">Rutger Saalmink</a>
(<a href="/recipes/tags/chronological/">chronological</a>, <a href="/recipes/tags/exif/">exif</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/order/">order</a>, <a href="/recipes/tags/photo/">photo</a>, <a href="/recipes/tags/picture/">picture</a>).
Revision 3.
</p>
<p>On some occasions/events, pictures will be taken by different camera's, mobile phones, etc. In order to sort these photos chronologically, it does not suffice using the file's date modified/created set by the OS. The following script obtains, from multiple sources, the pictures' taken date stored in the accompanying Exif data and outputs them all chronologically in a single directory.</p>
Voxel Based Ray Tracing (Python)
2013-08-29T06:11:41-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578652-voxel-based-ray-tracing/
<p style="color: grey">
Python
recipe 578652
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>The standard ray tracing algorithm seems unnatural to me because everytime a ray reflects/refracts all (primitive) objects in the scene must be tested for intersection; no matter where they located!</p>
<p>In this method there is no such thing. It just moves each ray voxel by voxel until it hits an opaque/reflective(/refractive) voxel.</p>
<p>I made many simplifications so the image is crude.</p>
parse png image (Python)
2013-05-27T22:02:07-07:00judyhttp://code.activestate.com/recipes/users/4186659/http://code.activestate.com/recipes/578534-parse-png-image/
<p style="color: grey">
Python
recipe 578534
by <a href="/recipes/users/4186659/">judy</a>
(<a href="/recipes/tags/height/">height</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/parse/">parse</a>, <a href="/recipes/tags/png/">png</a>, <a href="/recipes/tags/width/">width</a>).
</p>
<p>parse png image find all chunks width height</p>
Perlin Noise Generator (Python)
2013-02-23T05:23:24-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578470-perlin-noise-generator/
<p style="color: grey">
Python
recipe 578470
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>, <a href="/recipes/tags/pil/">pil</a>).
Revision 2.
</p>
<p>Perlin Noise Generator using Bilinear Interpolation.</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>
Auto Insert CSS Image Width/Height Macro: (JavaScript)
2011-11-16T15:23:03-08:00Skye Giordanohttp://code.activestate.com/recipes/users/4179718/http://code.activestate.com/recipes/577948-auto-insert-css-image-widthheight-macro/
<p style="color: grey">
JavaScript
recipe 577948
by <a href="/recipes/users/4179718/">Skye Giordano</a>
(<a href="/recipes/tags/css/">css</a>, <a href="/recipes/tags/height/">height</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/width/">width</a>).
</p>
<p>Based on the macro at <a href="http://community.activestate.com/forum/html-editing-img-tag-expansion-etc" rel="nofollow">http://community.activestate.com/forum/html-editing-img-tag-expansion-etc</a> I hacked together this alternate version that will auto insert the width: and height: of an image background in a CSS rule turning this:</p>
<p>background: url(http://server.com/myImg.jpg) 0 0 no-repeat;</p>
<p>...into this:</p>
<p>background: url(http://server.com/myImg.jpg) 0 0 no-repeat;
height: 252px;
width: 200px;</p>
Convert Image Format (Python)
2011-09-30T10:46:21-07:00s_h_a_i_ohttp://code.activestate.com/recipes/users/4177334/http://code.activestate.com/recipes/577886-convert-image-format/
<p style="color: grey">
Python
recipe 577886
by <a href="/recipes/users/4177334/">s_h_a_i_o</a>
(<a href="/recipes/tags/convert/">convert</a>, <a href="/recipes/tags/format/">format</a>, <a href="/recipes/tags/image/">image</a>).
Revision 2.
</p>
<p>Simple GUI to allow converting images from one format to another. Available formats are: .gif .jpg .png .tif .bmp Uses PIL.</p>
<p>This is short and direct enhancement from recipe <a href="http://code.activestate.com/recipes/180801-convert-image-format" rel="nofollow">http://code.activestate.com/recipes/180801-convert-image-format</a>. Two new features added:</p>
<ul>
<li>Optional deletion of the original image files.</li>
<li>Optional recursive file selection. Implemented using <a href="http://code.activestate.com/recipes/577230-file-path-generator-from-path-patterns/" rel="nofollow">http://code.activestate.com/recipes/577230-file-path-generator-from-path-patterns/</a></li>
</ul>
<p><strong>note</strong> This assumes recipe/577230 is located in filePattern.py (see first import below)</p>