Vignette is a Python library to create and manage thumbnails following the FreeDesktop standard.

Overview

Vignette

Vignette is a Python library to create and manage thumbnails following the FreeDesktop standard.

Thumbnails are stored in a shared directory so other apps following the standard can reuse them without having to generate their own thumbnails.

Vignette can typically be used in file managers, image browsers, etc.

Thumbnails are not limited to image files on disk but can be generated for other file types, for example videos or documents but also for any URL, for example a web browser could store thumbnails for recently visited pages or bookmarks.

Vignette by itself can only generate thumbnails for local files but can retrieve thumbnail for any file or URL, if another app generated a thumbnail for it. An app can also generate a thumbnail by its own means and use vignette to push that thumbnail to the store.

The range of files for which vignette can generate thumbnails depends on plugins as it supports third-party libraries and tools. For example, if the evince-thumbnailer command is installed, it will be able to generate thumbnails for PDF files.

Install

From PyPI:

pip install vignette

Documentation

The documentation can be read online.

This library has querying functions, that do not generate thumbnails, and can be used with files or URLs, that can be non-images:

  • build_thumbnail_path
  • try_get_thumbnail
  • is_thumbnail_failed

It has functions that have side effects, which write thumbnails, or "fail-files" (if a thumbnail couldn't be generated), they can require local-files (see the function's doc):

  • get_thumbnail
  • create_thumbnail
  • put_thumbnail
  • put_fail

Examples

Just ask for thumbnails of local images, automatically creating them if necessary:

import vignette

thumb_image = vignette.get_thumbnail('/my/file.jpg')
local_app_display(thumb_image)

Ask for a thumbnail or generate it manually, for example a web-browser generating pages previews, that this module can't do itself:

import vignette

orig_url = 'http://example.com/file.pdf'
thumb_image = vignette.try_get_thumbnail(orig_url, mtime=0) # mtime is not used in this example

if not thumb_image:
  thumb_image = vignette.build_thumbnail_path(orig_url, 'large')
  try:
    local_app_make_preview(orig_url, thumb_image)
  except NetworkError:
    vignette.put_fail(orig_url, 'mybrowser-1.0', mtime=0)
  else:
    thumb_image = vignette.put_thumbnail(orig_url, 'large', mtime=0)
  if is_thumbnail_failed(orig_url):
    thumb_image = 'error.png'

local_app_display(thumb_image)

Requirements

Vignette works with both Python 2 and Python 3.

Vignette requires at least one image backend to work properly. See the backends section below.

Backends

Vignette does not contain image format code. In order to generate a thumbnail from an image or update metadata as required by the Freedestkop standard, vignette uses external libraries. The dependencies are "lazy" though: if an external library is missing, vignette ignores it and falls back on other equivalent libs.

Backends are divided in 2 types:

  • thumbnail backends, which create a thumbnail image from a source image file, a source video file, or another input URL
  • metadata backends, which are used internally in vignette to manage the metadata of thumbnails

Vignette currently has thumbnail/metadata backends supporting:

  • Python Imaging Library (PIL)
  • PyQt
  • PythonMagick

One of these libraries is required for vignette to work in basic cases (thumbnailing local images).

Vignette has additional thumbnail backends to support these tools:

If a lib is not present, vignette continues to operate but thumbnails for certain file formats may not be generated.

License

Vignette is licensed under the WTFPLv2.

Version

Vignette is currently at version 5.0.0 and uses Semantic Versioning.

You might also like...
A collection of python scripts which help you programatically create PNGs or GIFs
A collection of python scripts which help you programatically create PNGs or GIFs

A collection of python scripts which help you programatically create PNGs or GIFs and their Metadata in bulk with custom rarity rates, upload them to OpenSea & list them for sale.

 Polyfoto - Create image mosaics.
Polyfoto - Create image mosaics.

Polyfoto Create image mosaics. Showcase "Before and After Science" by Brian Eno "Scott 3" by Scott Walker Installation Clone this repository to your l

Create a static HTML/CSS image gallery from a bunch of images.

gallerize Create a static HTML/CSS image gallery from a bunch of images.

Tool to create a Phunk image with a custom background
Tool to create a Phunk image with a custom background

Create Phunk image Tool to create a Phunk image with a custom background Installation Clone the repo git clone https://github.com/albanow/etherscan_sa

A Blender add-on to create interesting meshes using symmetry
A Blender add-on to create interesting meshes using symmetry

Procedural Symmetries This Blender add-on automates the process of iteratively applying a set of reflection planes to a base mesh. The result will con

Short piece of code to create a rainbow gif of gradual contours from two shapefiles
Short piece of code to create a rainbow gif of gradual contours from two shapefiles

rainbow-elevation-gif Short piece of code to create a rainbow gif of gradual con

QR-Generator - An awesome QR Generator to create or customize your QR's
QR-Generator - An awesome QR Generator to create or customize your QR's

QR Generator An awesome QR Generator to create or customize your QR's! Table of

Create a random fluent image based on multiple colors.
Create a random fluent image based on multiple colors.

FluentGenerator Create a random fluent image based on multiple colors. Navigation Example Install Update Usage In Python console FluentGenerator Fluen

Seaborn-image is a Python image visualization library based on matplotlib and provides a high-level API to draw attractive and informative images quickly and effectively.
Seaborn-image is a Python image visualization library based on matplotlib and provides a high-level API to draw attractive and informative images quickly and effectively.

seaborn-image: image data visualization Description Seaborn-image is a Python image visualization library based on matplotlib and provides a high-leve

Comments
  • Fix: must also add VERSION.txt to source distribution

    Fix: must also add VERSION.txt to source distribution

    The source distribution does not work. setup.py reads VERSION.txt, therefore this file must also be added to the source distribution. If you start from the source tree as created by python setup.py sdist (or from the one downloaded from PyPI), you'll get:

    $ python setup.py build
    Traceback (most recent call last):
      File "setup.py", line 8, in <module>
        with open('VERSION.txt') as fd:
    IOError: [Errno 2] No such file or directory: 'VERSION.txt'
    

    This PR fixes that.

    opened by RKrahl 3
  • Have metadata/generation backends?

    Have metadata/generation backends?

    To support thumbnailing non-image files, there could be 2 types of backends:

    • backends purely for generating thumbnails, i.e. for the create_thumbnail functions
    • backends for manipulating thumbnail metadata, i.e. for put_thumbnail, put_fail, etc.
    enhancement 
    opened by hydrargyrum 1
  • Add a way to selectively disable backends

    Add a way to selectively disable backends

    I use vignette for a tool that works with photos. It features an overview window that uses vignette to display the thumbnails of the images. If I clear the cache to force recreation of the thumbnails, I get the following error messages for each image when I open the overview window:

    Syntax Warning: May not be a PDF file (continuing anyway)
    Syntax Error: Couldn't find trailer dictionary
    Syntax Error: Couldn't find trailer dictionary
    Syntax Error: Couldn't read xref table
    Error opening PDF file.
    

    It's certainly not surprising that the PDF backend fails on a JPG file. The creation of the thumbnails succeeds nevertheless. But the error messages are still annoying. So I disable the backends that are not useful for my application with:

    for backcls in (vignette.OooCliBackend, 
                    vignette.PopplerCliBackend, 
                    vignette.FFMpegCliBackend):
        for i in reversed(range(len(vignette.THUMBNAILER_BACKENDS))):
            if isinstance(vignette.THUMBNAILER_BACKENDS[i], backcls):
                del vignette.THUMBNAILER_BACKENDS[i]
    

    This also speeds up creating the thumbnails by a factor of more then two.

    While this works, fiddling that deep in the guts of a third party library is certainly not good practice. So I'd like to get a better solution to select the backends that should be tried.

    opened by RKrahl 9
Owner
If you like free software, go to https://gitlab.com/hydrargyrum instead
null
The following program is used to swap the faces from two images.

Face-Swapping The following program is used to swap the faces from two images. In today's world deep fake technology has become really popular . As a

null 1 Jan 19, 2022
An executor that performs standard pre-processing and normalization on images.

An executor that performs standard pre-processing and normalization on images.

Jina AI 6 Jun 30, 2022
Gallery written in Python to manage your photos

GalleryMan Gallery written in Python to manage your photos Installation

Asian Cat 24 Dec 18, 2022
A python based library to help you create unique generative images based on Rarity for your next NFT Project

Generative-NFT Generate Unique Images based on Rarity A python based library to help you create unique generative images based on Rarity for your next

Kartikay Bhutani 8 Sep 21, 2022
📷 Python package and CLI utility to create photo mosaics.

?? Python package and CLI utility to create photo mosaics.

Loic Coyle 7 Oct 29, 2022
Using P5.js, Processing and Python to create generative art

Experiments in Generative Art Using Python, Processing, and P5.js Quick Links Daily Sketches March 2021. | Gallery | Repo | Done using P5.js Genuary 2

Ram Narasimhan 33 Jul 6, 2022
HtmlWebShot - A python3 package which Can Create Images From url, Html-CSS, Svg and from any readable file and texts with many setup features.

A python3 package which Can Create Images From url, Html-CSS, Svg and from any readable file and texts with many setup features

Danish 24 Dec 14, 2022
Create a QR-code Generator app using only Python.

QR-code_Generator Create a QR-code Generator app using only Python. This apps generated a QR code for a single link. Libraryes used in this app --> py

Soham P Phasalkar 1 Oct 17, 2021
Create a 2D mesh for an airfoil in GMSH using python.

GMSHFoil A simple class to create a 2D mesh for an airfoil in GMSH using python. Requirements pip install airfoils

Charilaos Mylonas 1 May 16, 2022
Create QR Code for link using Python

Quick Response QR is short and named for a quick read from a cell phone. Used to view information from transitory media and put it on your cell phone.

Coding Taggers 1 Jan 9, 2022