Skip to main content

Photofile

Version : 0.1.0 Author : Thomas Weholt <thomas@weholt.org> License : GPL v3.0 WWW : https://bitbucket.org/weholt/django-photofile Status : Experimental

About

  • Templatetags for thumbnail generation, supports automatic rotation based on EXIF.Orientation.

  • Planned routines for metadata handling (EXIF/IPTC/XMP).

How

<img src=”{% generate_thumbnail imagefile 100x100 crop %}”/>

Provides a templatetag called generate_thumbnail which takes two or three parameters:

Param #1 : an object (imagefile), like a model instance, with a property/field called unique_filename, complete_filename or filename. Photofile will check in that order.

Param #2: resolution, specified as <width>x<height>, like 320x280.

Param #3: optional “crop” - which will enforce cropping of the photo.

The thumbnail will be written in a dir called “thumbs” in your STATICFILES_DIRS or STATIC_ROOT. If no dir exists called thumbs, it will be created.

The generated thumbnail will be named <filename>_<width>x<height>.<extension>. When cropping is used it will be named <filename>_<width>x<height>_crop.<extension>. For instance, thumbnail for test.jpg in resolution 200x300 will be named test_200x300.jpg.

Photofile will try to use caching if enabled, but it caches the url to the thumbnail, not the image itself so it’s not very efficient yet.

NB! It’s highly recommended to have some way of ensuring that the filename given to photofile is unique. That’s why it will look for a property called unique_filename first.

Why another thumbnail app for django?

I’ve looked at sorl-thumbnail and others, and initially I wanted to use an existing project, but none of them supported automatic rotation based on EXIF.Orientation.

Installation

Alternative a) pip install django-photofile. Alternative b) download source, unpack and do python setup.py install. Alternative c) hg clone https://bitbucket.org/weholt/django-photofile and do python setup.py install.

Usage

In settings.py: 1. Add ‘photofile’ to your INSTALLED_APPS. 2. Set up caching if you want. 3. Add a dir to your STATICFILES_DIRS or set STATIC_ROOT.

In your template: {% load photofile_tags %}

<img src=”{% generate_thumbnail imagefile 200x300 %}”/> or <img src=”{% generate_thumbnail imagefile 100x100 crop %}”/>

Where imagefile is an object with at a property/field called: a) unique_filename or b) complete_filename or c) filename

Resolution is specified as <width>x<height>, for instance 640x480 and if you want to crop the photo add crop as shown in the example over.

Requirements

  • django

  • PIL

Metadata

Release files for Photofile 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Photofile 0.1.0
File Size Uploaded Provenance Actions
Photofile-0.1.0.zip 21.4 kB Without provenance Details for Photofile-0.1.0.zip

Release files / Photofile-0.1.0.zip

Download URL Photofile-0.1.0.zip
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4e0c4b47ef558be1b963462efdaee64d73633d2873dd456d0ebe4d36c04220e4
BLAKE2b-256 checksum
How to use checksums
4592870d2cb64b835693b1a1844a6530cf7bb48a0ba96f18e40a58565bbfa005
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for Photofile 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page