Code Monkey home page Code Monkey logo

photobotlib's Introduction

PhotoBot

A Pillow based layered compositions library. The original version is part of the NodeBox Library.

Original documentation: https://www.nodebox.net/code/index.php/PhotoBot

Landslide

A Photobot demo by Tom de Smedt. https://www.nodebox.net/code/index.php/Landslide

PhotoBot was initially a part of the NodeBox Library.

Since 2013 it has been updated to the current Python 2/3 and Pillow libraries.

This version works standalone with Python2.7, Python3.11 and is identical to the current NodeBox Library version.

Fundamental changes

canvas.draw() has a double functionality. In Nodebox1 it places the result in the content section of the document window.

The image is also written out to a folder "exports" with a name like "photobot_YYYY-MM-DD_HHMMSS.png" using the current datetimestamp.

If run from the Terminal, only the exports part is done.

If the exports folder does not fit your needs use canvas.export() as follows:

cv.export( name="/Full/Path/to/image.png", ext=".png", format="PNG" )

Extension and format follow Pillow Image.save rules

New functions & properties

  • property canvas.top adresses the top layer

  • property canvas.topindex returns the index of the top layer

  • property canvas.dup duplicates the top layer

Installation

python setup.py install

Usage

T.B.D. see examples folder.

Hints

python Kontaktabzug-1.py PATH-TO_IMAGE-FOLDER

creates a contact print of a folder. All other Layer_* examples demonstrate a single function.

Scanning your images with ImageWells

The collage examples make use of the yet unreleased "ImageWells" library of which a preliminary version is included in the examples folder.

Abbreviated example from "Example collage 1.py"

import imagewells
loadImageWell = imagewells.loadImageWell


imagewell = loadImageWell(
				bgsize=(1280, 1024),
				minsize=(256,256),
				pathonly=True,
				maxfilesize=100000000,
				maxpixellength=16000,
				additionals=additionals,
				imagewellfilename="imagewell.txt",
				tabfilename="imagewell.tab",
				ignoreDotFolders=False,
				ignoreFolderNames=('+offline',))

After a script uses loadImageWell() for the first time there should be a file imagewell.txt in the same folder as the script excuting.

The file imagewell.txt looks like this:

/Library/Desktop Pictures
C:\Windows\Web
/usr/share/backgrounds
/usr/share/wallpapers

Each line represents a path for a platform. The file is NL terminated and UTF-8 encoded.

The first line is the "Desktop Pictures" folder on macos.

Line 2 is for windows.

Lines 3+4 are for linux.

If a folder does not exist, it will be ignored. The idea is to put your own image folders into that file.

The parameters for loadImageWell are as follows:

  • bgsize=(w,h) - a tuple marking the size at which a image is designated 'background'. Usually the canvas size.

  • minsize=(w,h) - at least width>=w or height>=h for a image to be considered. If both are smaller, the image is ignored.

  • pathonly=True|False - if False, a tuple with: (path, filesize, lastmodified, mode, islink, w0, h0, proportion, frac) is returned.

  • addtionals=('folder',) - a list of folders to be added. If this is active, no caching is used.

  • imagewellfilename="imagewell.txt" - the name of the folderlist file to be read.

  • tabfilename="imagewell.tab" - the name of the resulting cache file.

  • ignoreDotFolders=False - ignore folders starting with a '.'. This is for MacOS '.thumbnails' folders which you usually want to ignore

  • ignoreFolderNames=('folder',) - a list of folder names. If a scanned folder STARTS with a name from that list, it will be ignored.

The resulting dictionary contains the following keys:

  • allimages - a list of all images

  • tiles - a list of images with: minsize <= image <= bgsize

  • backgrounds - a list of images considered backgrounds

  • landscape - a list of images where WIDTH >= HEIGHT

  • portrait - a list of images where WIDTH < HEIGHT

  • fractions - dictionary with all the fractions as keys. A fraction key looks like: '1024:575', '4:3' or '16:9'.

  • 'WxH largest', 'WxH smallest' and 'WxH median': accumulated sizes

    • 'WxH largest': (8003, 5622),
    • 'WxH median': (1074.9886462882096, 754.4748180494905),
    • 'WxH smallest': (566, 167),

The items of each image list key will depend on the pathonly parameter.

Examples

See "examples/Example collage *.py"

See "examples/Layer_function_*.py"

photobotlib's People

Contributors

karstenw avatar

Stargazers

 avatar

Watchers

 avatar

photobotlib's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.