New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format forcing on new image creation #32

Merged
merged 2 commits into from Aug 11, 2012

Conversation

2 participants
@wronglink
Contributor

wronglink commented Aug 9, 2012

Sometimes imagemagick needs filename to detect file format. So when image is
created via blob or file arguments library raises an exeption. There is one
trick I've found here.
The idea is to set filename via MagickSetFilename magickwand method.

Here is a little example of my words:

>>> import requests
>>> from wand.image import Image
>>> r = requests.get('http://google.com/favicon.ico')
>>> img = Image(blob=r.content)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "wand/image.py", line 348, in __init__
    self.raise_exception()
  File "wand/resource.py", line 219, in raise_exception
    raise e
MissingDelegateError: no decode delegate for this image format `' @ error/blob.c/BlobToImage/364
>>> img = Image(blob=r.content, format='ico')
>>> img.size
(16L, 16L)
Format forcing on new image creation
Sometimes imagemagick needs filename to detect file format. So when image is
created via blob or file arguments library raises an exeption. There is one
trick I've found [here](http://www.assembla.com/spaces/pythonmagickwand/wiki).
The idea is to set filename via MagickSetFilename magickwand method.

Here is a little example of my words:

    >>> import requests
    >>> from wand.image import Image
    >>> r = requests.get('http://google.com/favicon.ico')
    >>> img = Image(blob=r.content)
    Traceback (most recent call last):
      File "<input>", line 1, in <module>
      File "wand/image.py", line 348, in __init__
        self.raise_exception()
      File "wand/resource.py", line 219, in raise_exception
        raise e
    MissingDelegateError: no decode delegate for this image format `' @ error/blob.c/BlobToImage/364
    >>> img = Image(blob=r.content, format='ico')
    >>> img.size
    (16L, 16L)
@dahlia

This comment has been minimized.

Collaborator

dahlia commented Aug 9, 2012

Could you write a small test for this? Thanks!

@wronglink

This comment has been minimized.

Contributor

wronglink commented Aug 9, 2012

Sure.

dahlia added a commit that referenced this pull request Aug 11, 2012

Merge pull request #32 from wronglink/master
Format forcing on new image creation

@dahlia dahlia merged commit 2bb2a3d into emcconville:master Aug 11, 2012

dahlia added a commit that referenced this pull request Aug 11, 2012

dahlia added a commit that referenced this pull request Aug 11, 2012

dahlia added a commit that referenced this pull request Aug 11, 2012

dahlia added a commit that referenced this pull request Aug 11, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment