Giter VIP home page Giter VIP logo

sorl-thumbnail's Introduction

Jazzband sorl-thumbnail on PyPI Supported Python versions Supported Python versions Documentation for latest version gh-actions Coverage

Thumbnails for Django.

Features at a glance

  • Support for Django 3.2, 4.0 and 4.1 following the Django supported versions policy
  • Python 3 support
  • Storage support
  • Pluggable Engine support for Pillow, ImageMagick, PIL, Wand, pgmagick, and vipsthumbnail
  • Pluggable Key Value Store support (cached db, redis, and dynamodb by AWS)
  • Pluggable Backend support
  • Admin integration with possibility to delete
  • Dummy generation (placeholders)
  • Flexible, simple syntax, generates no html
  • ImageField for model that deletes thumbnails (only compatible with django 1.2.5 or less)
  • CSS style cropping options
  • Back smart cropping, and remove borders from the images when cropping
  • Margin calculation for vertical positioning
  • Alternative resolutions versions of a thumbnail

Read more in the documentation (latest version)

Developers

Jazzband

This is a Jazzband project. By contributing you agree to abide by the Contributor Code of Conduct and follow the guidelines.

Feel free to create a new Pull request if you want to propose a new feature. If you need development support or want to discuss with other developers join us in the channel #sorl-thumbnail at freenode.net or Gitter.

For releases updates and more in deep development discussion use our mailing list in Google Groups.

Tests

The tests should run with tox and pytest. Running tox will run all tests for all environments. However, it is possible to run a certain environment with tox -e <env>, a list of all environments can be found with tox -l. These tests require the dependencies of the different engines defined in the documentation. It is possible to install these dependencies into a vagrant image with the Vagrantfile in the repo.

User Support

If you need help using sorl-thumbnail browse https://stackoverflow.com/questions/tagged/sorl-thumbnail and posts your questions with the sorl-thumbnail tag.

How to Use

Get the code

Getting the code for the latest stable release use 'pip'. :

$ pip install sorl-thumbnail

Install in your project

Then register 'sorl.thumbnail', in the 'INSTALLED_APPS' section of your project's settings. :

INSTALLED_APPS = [
    'django.contrib.auth',
    'django.contrib.admin',
    'django.contrib.sites',
    'django.contrib.comments',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.contenttypes',

    'sorl.thumbnail',
]

Templates Usage

All of the examples assume that you first load the thumbnail template tag in your template.:

{% load thumbnail %}

A simple usage. :

{% thumbnail item.image "100x100" crop="center" as im %}
    <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endthumbnail %}

See more examples in the section Template examples in the Documentation

Model Usage

Using the ImageField that automatically deletes references to itself in the key value store and its thumbnail references and the thumbnail files when deleted. Please note that this is only compatible with django 1.2.5 or less.:

from django.db import models
from sorl.thumbnail import ImageField

class Item(models.Model):
    image = ImageField(upload_to='whatever')

See more examples in the section Model examples in the Documentation

Low level API

You can use the 'get_thumbnail':

from sorl.thumbnail import get_thumbnail
from sorl.thumbnail import delete

im = get_thumbnail(my_file, '100x100', crop='center', quality=99)
delete(my_file)

See more examples in the section Low level API examples in the Documentation

Using in combination with other thumbnailers

Alternatively, you load the templatetags by {% load sorl_thumbnail %} instead of traditional {% load thumbnail %}. It's especially useful in projects that do make use of multiple thumbnailer libraries that use the same name (thumbnail) for the templatetag module:

{% load sorl_thumbnail %}
{% thumbnail item.image "100x100" crop="center" as im %}
    <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endthumbnail %}

Frequently asked questions

Is so slow in Amazon S3!

Possible related to the implementation of your Amazon S3 Backend, see the issue #351 due the storage backend reviews if there is an existing thumbnail when tries to generate the thumbnail that makes an extensive use of the S3 API

A fast workaround if you are not willing to tweak your storage backend is to set:

THUMBNAIL_FORCE_OVERWRITE = True

So it will avoid to overly query the S3 API.

sorl-thumbnail's People

Contributors

aleksihakli avatar askedrelic avatar beholderrk avatar benjaoming avatar caioariede avatar camilonova avatar claudep avatar coagulant avatar dnmellen avatar flimm avatar frankier avatar gregplaysguitar avatar haakenlid avatar hramezani avatar jezdez avatar joke2k avatar julian-amaya avatar kingtut avatar larrymartell avatar mariocesar avatar matthiask avatar pygeek avatar relekang avatar renecarvalho avatar schnouki avatar sorl avatar timgraham avatar uri-rodberg avatar wm3ndez avatar yourcelf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sorl-thumbnail's Issues

Add support for custom cropping (javascript)

Motivation: Sometimes thumbnails need special treatment and some user-fined control. Thus javascript libraries like JCrop have to be used.

Implementation details: Sorl is more or less ready for such usage except the cropping options. Custom cropping support should be added by saying x, y, x2, y2. JCrop can be released later as an addon.

I'm willing to provide a patch if this sounds reasonable.

Image format inheritance

I'd like my thumbnails to use the same format as the original file instead of using jpg or png throughout. Would a patch that implements that be acceptable, or was there a reason that functionality was avoided?

Add THUMBNAIL_FALLBACK_IMAGE setting

When image path is empty or don't exists, use fallback placeholder. Difference from THUMNAIL_DUMMY is that's works only when picture is empty or don't exists.

Sorry for my english.

Problem with gm

When using Graphicsmagick the command line call fails.

Issue:
THUMBNAIL_CONVERT = '/usr/bin/gm convert'
THUMBNAIL_IDENTIFY = '/usr/bin/gm identify'

subprocess.Popen expects ['/usr/bin/gm', 'convert', ...] instead of ['/usr/bin/gm convert', ...](-> thumbnail/engines/convert_engine.py)

Temporary workaround:
Splitting THUMBNAIL_CONVERT and THUMBNAIL_IDENTIFY and having 2 elements.
p = Popen(settings.THUMBNAIL_IDENTIFY.split(' ') + [tmp])

I can provide a more elegant solution, if desired.

Thanks for sorl,
Dominik

feature request

It would be great to have following feature:

If model Foo has the logo image field and its admin class is derived from AdminImageMixin then we can add logo_foo to list_display and get thumbnails in the change list in admin interface.

class Foo(models.Model):
logo = models.ImageField()

class FooAdmin(AdminImageMixin, admin.ModelAdmin):
list_display = [...., 'logo_thumbnail']

Maybe it is already done? I have not found solution. If you thnk it is good idea I can do it myself and then send you pull request.

Clarify whether sorl-thumbnail depends on Django or not

Hi!

I am working on a native RPM package for solr-thumbnail for Red Hat Enterprise Linux and Fedora. Could you please help me to chose the right package name? I am not quite sure whether I should go for python-django-solr-thumbnail or python-solr-thumbnail.

If the package is an app / addon for Django and depends on Django it should have 'django' in the name. If it can be used outside of Django and is a generic Python package, I should skip 'django'.

Please clarify!

Thanks,
Z.

Breaking 'engines' submodules out

I've been looking at sorl's 'engines' sub-module as a solution to some issues with my company's more S3-specialized thumbnailer, and had the idea that we could perhaps improve the Python imaging ecosystem as a whole with a small bit of effort.

I'll be breaking your 'engines' sub-module out into its own Python module over the next few weeks. That code, by design, is already close to stand-alone. The idea is that various basic image manipulation applications (thumbnailers in particular) could share your well-done 'engines', and instead focus on the storage and developer-facing stuff like abstractions and methods. Image manipulation with PIL, pgmagic, and convert is boring, and it stinks for each thumbnail application to have to re-invent the wheel, when we could all benefit from a simple, well-tested set of classes for doing basic things (which is what you've put together).

I'm leaving most of the code un-changed, aside from some cosmetic things and commenting/documentation/unit testing. If this is something you'd be interested in, I can get it up on GitHub soon and we could look at how to make this as generic and useful to others as possible.

Throw an exception when cache not working

Hi!

I'm writing because I wasn't aware that I needed to run manage.py syncdb in order to get the cache engine fully working. Also, I sometimes forget to create a cache directory and set the permissions correctly.

It would be nice, if using the template tag would cast an exception when the caching backend fails.

But thanks for a great plugin!! I love the syntax for the template tag, and installation is super easy.

//Benjamin

convert_engine is_valid_image() bug

I'm getting this error when using THUMBNAIL_ENGINE=sorl.thumbnail.engines.convert_engine.Engine

Upload a valid image. The file you uploaded was either not an image or a corrupted image.

This is happening when I try to upload an image that is less than 4,096 bytes, so python does not flush the buffer on the file, and "identify" ends up reading an empty file. Adding fp.flush() before calling Popen() will fix this, or you could just pipe in the file data into "identify -". I'm getting this error with sorl version 11.05.2 on Ubuntu 10.10 with python package at version 2.6.6-2ubuntu2.

def is_valid_image(self, raw_data):
    """
    This is not very good for imagemagick because it will say anything is
    valid that it can use as input.
    """
    handle, tmp = mkstemp()
    with open(tmp, 'w') as fp:
        fp.write(raw_data)
        p = Popen([settings.THUMBNAIL_IDENTIFY, tmp])
        retcode = p.wait()
    os.close(handle)
    os.remove(tmp)
    return retcode == 0

KVStore backend for Django

Having the thumbnailing create queries for each thumbnail is sick. It also makes you have to setup something else again next to the django cache already in use.

So here is the DjangoCache KVStoreBase.

from django.core.cache import cache

from sorl.thumbnail.kvstores.base import KVStoreBase

class DjangoCache(KVStoreBase):

    def _get_raw(self, key):
        return cache.get(key)

    def _set_raw(self, key, value):
        return cache.set(key, value)

    def _delete_raw(self, *keys):
        return cache.delete_many(keys)

    def _find_keys_raw(self, prefix):
        """
            Can't implement this
        """
        return []

Support Python 2.5

Hi,

I'm happy to fork and tackle this myself but do you have a rough idea of whether it's a small tweak or a big job?

Allow documentation to build with python-sphinx 0.6+

Hi!

Right now I have to following in my SPEC:

%if 0%{?el6}
    %{__sed} -i -e "s/, 'sphinx.ext.viewcode'//" docs/conf.py
    %{__sed} -i -e 's/nature/default/' docs/conf.py
%endif

I see that you have apparently added nature in git, but could you please also make viewcode conditional, otherwise the docs won't build with older Sphinx.

Thanks!

pgmagick image quality

The quantize call is reducing the colors too much, I can see dithering effects. Have tried specifying quantizeColors() but this doesn't seem to fix the problem. Tips from anyone with more knowledge of color spaces will be appreciated.

For now I have subclassed the engine and simply return the image in the _colorspace method.

encode salt before md5

tokey function in helpers.py should encode salt from unicode before calling md5. If sending unicode string to md5 with non-ascii characters it fails.

 def toint(number):
     """
     Helper to return rounded int for a float or just the int it self.
@@ -31,13 +23,18 @@ def tokey(*args):
     """
     Computes a (hopefully) unique key from arguments given.
     """
-    salt = '||'.join([smart_str(arg) for arg in args])
+    salt = ('||'.join([force_unicode(arg) for arg in args])).encode('utf-8')
     hash_ = hashlib.md5(salt)
     return hash_.hexdigest()
'''

South migration issues

On schemamigration, i get the following.

! Cannot freeze field 'ads.ad.image'

! South cannot introspect some fields; this is probably because they are custom
! fields. If they worked in 0.6 or below, this is because we have removed the
! models parser (it often broke things).
! To fix this, read http://south.aeracode.org/wiki/MyFieldsDontWork

Might make it easier for people that use south to include the following, in fields.py, within try/except?

from south.modelsinspector import add_introspection_rules
add_introspection_rules([], ["^sorl\.thumbnail\.fields\.ImageField"])

Problem with MS SQL Server

In the odd case that you're in my position and need to run Django with an MS SQL Server database you get a database error when running syncdb if sorl.thumbnail is in your installed apps.

I get the following error message when running syncdb using MS SQL Server as my database:

pyodbc.ProgrammingError: ('42000', "[42000] [FreeTDS][SQL Server]Incorrect syntax near the keyword 'key'. (156) (SQLExecDirectW)")

The cause of this problem is most likely that the class KVStore in sorl.thumbnail.models has an attribute called "key", which is a reserved keyword in MS SQL Server.

Possible solution: Change the name of the "key" attribute

MS SQL Server reserved keywords

Serving Static Files

I can't find any way to thumbnail a static (in STATIC_ROOT) file. It only seems to work on external (http://....) and media (in MEDIA_ROOT) files.

This is very helpful when the output size of a static image is not always the same (be it through user preferences, theming, etc)

django.db.models.Model subclasses change ImageField to FileFields.

I'm a n00b. But following your example::

from django.db import models
from sorl.thumbnail import ImageField
class Item(models.Model):
image = ImageField()

I get this error in Django 1.2.4:
... "image": FileFields require an "upload_to" attribute.

However, it works if I don't subclass django.db.models.Model. I know that FileField is the parent class of Django's ImageField. It's this some kind of naming conflict?

Preserve "progressiveness" of JPEG files

Most of all JPEG files uploaded to my sites are saved in progressive format, but no thumbnail generated by sorl-thumbnail is generated as progressive when the original image is. This is essential when creating thumbnails of large images, for instance, for display within a carousel/slider.

Is there a quick way to workaround this, like a custom backend based on the existing ones?

redis kvstore not working

Hi

I am using Django 1.3 with a functional redis cache.
settings:

CACHES = {
    'default': {
        'BACKEND': 'redis_cache.RedisCache',
        'LOCATION': '127.0.0.1:6379',
        'OPTIONS': { # optional                                                                                                                                                                                                              
            'DB': 1,
            },
        }
    }

I am trying to use redis kvstore for sorl thumbnail also
settings:

DEBUG = True
TEMPLATE_DEBUG = DEBUG
THUMBNAIL_DEBUG = True
THUMBNAIL_KVSTORE = 'sorl.thumbnail.kvstores.redis_kvstore.KVStore'
THUMBNAIL_ENGINE = 'sorl.thumbnail.engines.pil_engine.Engine'

But when I load the page which contains the required thumbnail I get an error:

Caught OSError while rendering: [Errno 13] Permission denied: '/var/www/cache/91'

Which means it is trying to access the file system.

However, the operation documentation at http://thumbnail.sorl.net/operation.html says that

If the key for the thumbnail is found in the Key Value Store, the serialized thumbnail information is fetched from it and returned.

My question is, after having the redis kvstore why should it still access the file system?

Does the sorl-thumnail will support the python-2.5?

Hello, I try to install the sorl-thumbnail from pypi with:

$ pip install sorl-thumbnail

and I got whis error:

  File "/tmp/python/lib/python2.5/site-packages/sorl/thumbnail/fields.py", line 69
    with open(data.temporary_file_path(), 'rb') as fp:
            ^
SyntaxError: invalid syntax

  File "/tmp/python/lib/python2.5/site-packages/sorl/thumbnail/templatetags/thumbnail.py", line 52
    class ThumbnailNode(ThumbnailNodeBase):
        ^
SyntaxError: invalid syntax

The previous version of the sorl-thumbnail (3.2.5) works with python-2.5.
Would you plan to maintain compability with python-2.5 in the next release?

Django 1.3 and sorl: forces to upload the image again

Given:

from sorl.thumbnail.fields import ImageField

class Banner(models.Model):
"""Banners para la web"""

def get_upload_path(instance, filename):
    return "banners/%s/%s" % (instance.tipo.slug, filename)

name = models.CharField(max_length=100)
original_image  = ImageField(upload_to=get_upload_path)

class BannerAdmin(AdminImageMixin, admin.ModelAdmin):
list_display = ('thumb', 'name'')

def thumb(self, obj):
    if obj.original_image:
        try:
            im = get_thumbnail(obj.original_image, '50x50', crop='center', quality=90)
            return '<img src="%s">' % im.url
        except IOError: pass
    return "No Thumbnail"
thumb.allow_tags = True
thumb.short_description = 'Img'

I can upload images and display the thumbnail without problems, but when I try to update the record gives an error and requires the image. In the admin is not showing the image path.

Possible Unicode argument marshalling issue

Background: using pgmagick on Ubuntu. PNG format used for better transparency handling.

{% thumbnail my_organization.logo "160" format="PNG" as im %}

Last line of error traceback:

File "/srv/.virtualenvs/open_government/src/sorl-thumbnail/sorl/thumbnail/engines/pgmagick_engine.py", line 61, in get_raw_data
image.magick(format
)

ArgumentError: Python argument types in
Image.magick(Image, SafeUnicode)
did not match C++ signature:
magick(Magick::Image {lvalue})
magick(Magick::Image {lvalue}, std::string)

the code of pgmagick engine method is

def _get_raw_data(self, image, format_, quality):
    image.magick(format_)
    image.quality(quality)
    blob = Blob()
    image.write(blob)
    return get_blob_data(blob)

The problem seem to be is that format_ is a unicode string and magick wants std string. I've made a patch which converts format_ to ascii (via .encode) and now everything is fine.

Please check is it a platform/configuration issue or it is a common problem.

sorl.thumbnail.engines.PIL: "No module named PIL"

Hello! Setting sorl.thumbnail (10.12), got an error:

Error importing module sorl.thumbnail.engines.PIL: "No module named PIL"

Surprised, because PIL running other applications without problems generates images. The file site-packages/sorlthumbnail-10.12beta2-py2.7.egg/sorl/thumbnail/engines/PIL.py and saw:

from ..PIL import Image, ImageDraw
...

I replaced ..PIL on PIL and receive another error:

Error importing module sorl.thumbnail.engines.PIL: "cannot import name Image"

Battlefield: OS Debian Lenny, Python 2.7, Django 1.2.3, (Apache mod_wsgi)

I cry for help ...

Google Code page raises 403 error

Hi Mikko,

I used to install the sorl-thumbnails from google code checkout (http://code.google.com/p/sorl-thumbnail/ ) and now the deployment of some my old sites is broken because this repo is shut down. Can you please bring the repo back?

I think there was some unreleased features in the googlecode repo and the code in this repo is rewritten and incompatible.

Management commands fail with "invalid syntax"

If I run either of:

python manage.py thumbnail clear
python manage.py thumbnail cleanup

I get a traceback, ending in:

File "/home/shacker/lib/python2.4/sorl/thumbnail/fields.py", line 61
with open(data.temporary_file_path(), 'rb') as fp:
^
SyntaxError: invalid syntax

Thanks.

maximum pixel size for ImageField

We deploy on a memory constrained environment with a fixed top memory limit per process, so we can get OOM errors easily with big images. Big from my experience means an image with an area bigger than 1920x1080 with 64MB of RAM processed with PIL. So an argument for the formfield where we can define a max for the picture area size to avoid the upload of too big images we would not be able to process would be helpful.

Type of instance fields is FileField instead of ImageField

from sorl.thumbnail import ImageField

Create a model with:

image = ImageField(upload_to='path/to')

If I have an instance of that model and I do:

type(instance.image)

I get:

<class 'django.db.models.fields.files.FieldFile'>

instead of a sorl ImageField.

sorl-thumbnail 11.01

When specifying:

THUMBNAIL_KVSTORE = 'sorl.thumbnail.kvstores.cached_db_kvstore.KVStore'

It's ending up using mysql (what we are using for most everything else). I was under the impression this was using a local cachedb and not the default storage system?

PNG feature request

Hi

I like sorl-thumbnail, great app. A nice additional feature would be if PNG files could be scaled and saved as PNG files without loosing the transparency feature.

When using a PNG the rendered thumbnail currently results in a JPG. In this conversion the transparancy is unfortunately lost.

An example is here: http://tinyurl.com/3o9v4lv (a link to Picassa, the second picture is the original png.)

Or am I doing something wrong and should it work?

Best regards

Guido

Add default=... option to reduce writing the same code a lot !

https://gist.github.com/719942

I want a way to specify a default image which should be thumbnailed in exactly the same way as the official image in case the official image is empty.
Now I have this setup all over my templates so I can get a propperly sized default image.

This way when a user uploads a new picture it will have a newer timestamp and thus should be replaced with a new thumbnail.

Usage of download_url on pypi breaks old releases

Hi

Because you have a download_url set on pypi (for whatever reason, pypi can host files you know), it's not possible to install 3.2.5 anymore. The file is on pypi, but since there's a download url, any installer tool will try that instead of the pypi file. You can fix this on pypi by editing that release and remove the download url.

Is the nested template tag really necessary?

I have some issues with the new template syntax:

{% thumbnail item.image "200" as im %}
    <img src="{{ im.url }}">
{% endthumbnail %}

Aside from breaking all existing templates for no apparent reason, what is the real benefit here? I can see that the nesting limits the scope of the im variable, but for what purpose? I think there are actual drawbacks. Suppose you wanted to use the same thumbnail several times throughout a longer block of template code -- you're going to have to wrap the whole block in a thumbnail/endthumbnail block.

So in my opinion, this just complicates writing templates and makes them more verbose.

I suppose the whole reason for this is the {% empty %} feature. But, for the few cases where you are not actually sure whether what you're trying to create a thumbnail from is indeed an image, you could just as well solve it like this:

{% thumbnail item.image "200" as im %}
{% if im %}
...valid thumbnail
{% else %}
...invalid source
{% endif %}

Template tag should accept geometry tuple instead of string

It used to be possible to pass the tag a tuple (width, height), which was very practical. Now a string is expected. This breaks existing templates, and you have to do string manipulation (concat width, "x", height) instead of just passing a tuple along with the context. Wouldn't this be easy to restore?

Allow iteration of sorl.thumbnail.images.ImageFile

It would be nice to be able to stream thumbnail programmatically generated using get_thumbnail as the content of a HTTPResponse like you can with Django's built in file/image field types. If sorl.thumbnail.images.ImageFile implemented iter this would be possible.

Problem with unicode file names

When the image file name contains non-english letters, thumbnail tag outputs nothing. It even do not output "empty" content. And there is no any exception.

IOError: broken data stream when reading image file

I'm using sorl thumbnail with Django. On my local setup it works fine, but in production the thumbnails are not made.

My code looks like this:

{% load thumbnail %}
{% thumbnail up.image "32x32" crop="center" as im %}

{% empty %}

{% endthumbnail %}

I enabled logging and the trace looks like this:

Traceback (most recent call last):

File "/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/templatetags/thumbnail.py",
line 45, in render
return self._render(context)

File "/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/templatetags/thumbnail.py",
line 97, in render
file
, geometry, **options

File "/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/base.py",
line 49, in get_thumbnail
thumbnail)

File "/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/base.py",
line 74, in _create_thumbnail
image = default.engine.create(source_image, geometry, options)

File "/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/engines/base.py",
line 14, in create
image = self.colorspace(image, geometry, options)

File "/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/engines/base.py",
line 24, in colorspace
return self._colorspace(image, colorspace)

File "/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/engines/pil_engine.py",
line 33, in _colorspace
return image.convert('RGB')

File "/usr/local/lib/python2.6/dist-packages/PIL/Image.py", line 679,
in convert
self.load()

File "/usr/local/lib/python2.6/dist-packages/PIL/ImageFile.py", line
215, in load
raise_ioerror(e)

File "/usr/local/lib/python2.6/dist-packages/PIL/ImageFile.py", line
52, in raise_ioerror
raise IOError(message + " when reading image file")

IOError: broken data stream when reading image file

The error isn't very helpful since the file is there and is readable by all. I'm not sure how to get a more explicit error, or what to try and fix.

get_thumbnail() error

This from your examples is giving me an error:

from sorl.thumbnail import get_thumbnail
im = get_thumbnail(my_file, '100x100', crop='center', quality=99)

this is the error:

Could not import smapp.api. Error was: cannot import name get_thumbnail

I'm doing something wrong?

in the templates sorl.thumbnail is working perfect.

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.