Popular recipes tagged "png"http://code.activestate.com/recipes/tags/png/2016-09-28T12:03:59-07:00ActiveState Code RecipesExtract images of a PDF - optionally by page using PyMuPDF / fitz (Python)
2016-09-28T12:03:59-07:00Jorj X. McKiehttp://code.activestate.com/recipes/users/4193772/http://code.activestate.com/recipes/580703-extract-images-of-a-pdf-optionally-by-page-using-p/
<p style="color: grey">
Python
recipe 580703
by <a href="/recipes/users/4193772/">Jorj X. McKie</a>
(<a href="/recipes/tags/fitz/">fitz</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/png/">png</a>).
</p>
<p>Two small scripts to extract images contained in a PDF document as PNG files.
(1) Script 1 extracts <strong>all</strong> images
(2) Script 2 extracts only images that are referenced by a page</p>
Create Tiles of Images with fitz / MuPDF (PyMuPDF) (Python)
2016-04-26T19:54:31-07:00Jorj X. McKiehttp://code.activestate.com/recipes/users/4193772/http://code.activestate.com/recipes/580629-create-tiles-of-images-with-fitz-mupdf-pymupdf/
<p style="color: grey">
Python
recipe 580629
by <a href="/recipes/users/4193772/">Jorj X. McKie</a>
(<a href="/recipes/tags/mupdf/">mupdf</a>, <a href="/recipes/tags/png/">png</a>, <a href="/recipes/tags/pymupdf/">pymupdf</a>, <a href="/recipes/tags/tiles/">tiles</a>).
Revision 4.
</p>
<p>Take an image file (like PNG) and create a new one consisting of arbitrary tiles of the original (or overlay an existing image with selective tiles of another).</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>
Using pngcanvas, a pure Python PNG library (Python)
2014-01-15T22:45:11-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/578811-using-pngcanvas-a-pure-python-png-library/
<p style="color: grey">
Python
recipe 578811
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/image_processing/">image_processing</a>, <a href="/recipes/tags/imaging/">imaging</a>, <a href="/recipes/tags/png/">png</a>, <a href="/recipes/tags/pngcanvas/">pngcanvas</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>This recipe shows a simple example of how to use pngcanvas, a pure Python library for PNG image creation.</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>
mouse click to crop many large photos quickly [Python, PIL, pygame] (Python)
2012-01-09T03:18:01-08:00Elliot Hallmarkhttp://code.activestate.com/recipes/users/4180468/http://code.activestate.com/recipes/578005-mouse-click-to-crop-many-large-photos-quickly-pyth/
<p style="color: grey">
Python
recipe 578005
by <a href="/recipes/users/4180468/">Elliot Hallmark</a>
(<a href="/recipes/tags/crop/">crop</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/jpeg/">jpeg</a>, <a href="/recipes/tags/mouse/">mouse</a>, <a href="/recipes/tags/pil/">pil</a>, <a href="/recipes/tags/png/">png</a>).
</p>
<p>Waste no mouse clicks making multiple crops on many image files. Through pygame interface with pan, zoom and next/previous image. Saves files at new resolution and serialized names in a seperate folder. the mainloop() and helper functions are easy to reuse, but I include a cruddy text based interface if needed. if not, comment out most of __main__().</p>
<p>Requires PIL (python imaging library) and pygame.</p>
Write a PNG image in native Python (Python)
2010-10-28T12:03:52-07:00Campbell Bartonhttp://code.activestate.com/recipes/users/4168177/http://code.activestate.com/recipes/577443-write-a-png-image-in-native-python/
<p style="color: grey">
Python
recipe 577443
by <a href="/recipes/users/4168177/">Campbell Barton</a>
(<a href="/recipes/tags/alpha/">alpha</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/pil/">pil</a>, <a href="/recipes/tags/png/">png</a>, <a href="/recipes/tags/save/">save</a>).
</p>
<p>This is a simple PNG writing function, intended to be as small as possible.
It only supports RGBA 32bit PNGs and the input should be a buffer of rgba bytes.</p>
<p>Tested for python 2 and 3.</p>