Majic Projects
Pydenticon
Go to the previous open issue
Go to the previous issue (open or closed)
star_faded.png
Please log in to bookmark issues
icon_project.png Pydenticon / Closed Bug report PYD-8 Cannot generate identicons in JPEG format when using Pillow >= 4.2.0
Go to the next issue (open or closed)
Go to the next open issue
This issue has been closed with status "Closed" and resolution "RESOLVED".
Issue basics
  • Type of issue
    Bug report
  • Category
    General
  • Targetted for
    0.3.1
  • Status
    Closed
  • Progress
  • Priority
    Not determined
User pain
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
Affected by this issue (2)
People involved
Times and dates
  • Posted at
  • Last updated
  • Estimated time
    2 hours
  • Time spent
    2 hours
    Click here to see time logged against this issue
Issue details
  • Resolution
    RESOLVED
  • Reproducability
    Always
  • Severity
    Not determined
Attachments (0)
There is nothing attached to this issue
Duplicate issues (0)
This issue does not have any duplicates
Description

Generating an identicon in JPEG format fails with an exception.

The reason for this is that starting with Pillow 4.2.0, saving an RGBA image as JPEG will not silently discard the alpha channel during conversion (since JPEG does not support this), and it is explicitly necessary to convert toe RGB mode before generating the JPEG.

It should be noted that when running tests using Pillow 4.1.x, the following deprecation warning is shown:

    test_generate_format (tests.test_pydenticon.GeneratorTest) ... /home/branko/.virtualenvs/pydenticon_py3/lib/python3.4/site-packages/PIL/JpegImagePlugin.py:611: DeprecationWarning: You are saving RGBA image as JPEG. The alpha channel will be discarded. This conversion is deprecated and will be disabled in Pillow 3.7. Please, convert the image to RGB explicitly.
      DeprecationWarning

This should be an easy fix, and a pull request had already been submitted at Github mirror

Steps to reproduce this issue

Reproduction steps:

  1. Unpack version 0.3 of Pydenticon and prepare new virtual environment for it.

  2. Install Pillow 4.2.x:

    pip install pillow~=4.2.0
  3. Run tests:

    python setup.py test

Expected results:

  1. All tests succeed.

Actual results:

  1. Tests fail with the following result:

            ======================================================================
    ERROR: test_generate_format (tests.test_pydenticon.GeneratorTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/branko/projects/pydenticon/tests/test_pydenticon.py", line 242, in test_generate_format
        raw_image = generator.generate(data, 200, 200, output_format="jpeg")
      File "/home/branko/projects/pydenticon/pydenticon/__init__.py", line 338, in generate
        return self._generate_image(matrix, width, height, padding, foreground, background, output_format)
      File "/home/branko/projects/pydenticon/pydenticon/__init__.py", line 251, in _generate_image
        image.save(stream, format=image_format, optimize=True)
      File "/home/branko/.virtualenvs/pydenticon_test/lib/python2.7/site-packages/PIL/Image.py", line 1893, in save
        save_handler(self, fp, filename)
      File "/home/branko/.virtualenvs/pydenticon_test/lib/python2.7/site-packages/PIL/JpegImagePlugin.py", line 604, in _save
        raise IOError("cannot write mode %s as JPEG" % im.mode)
    IOError: cannot write mode RGBA as JPEG
    
    ----------------------------------------------------------------------
    Ran 15 tests in 0.063s
    
    FAILED (errors=1)
    Test failed: <unittest.runner.TextTestResult run=15 errors=1 failures=0>
    error: Test failed: <unittest.runner.TextTestResult run=15 errors=1 failures=0>
Todos (0 / 0)
There are no comments