We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
PySide2
The PySide2 (Qt for Python)[1] project developed by qt is now available even in pypi[2], I have always changed ImageQt.py manually, but I think it's time to add such changing to the official source

[1] https://wiki.qt.io/Qt_for_Python
[2] https://pypi.org/project/PySide2

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/PIL/ImageQt.py`
Content:
```
1 #
2 # The Python Imaging Library.
3 # $Id$
4 #
5 # a simple Qt image interface.
6 #
7 # history:
8 # 2006-06-03 fl: created
9 # 2006-06-04 fl: inherit from QImage instead of wrapping it
10 # 2006-06-05 fl: removed toimage helper; move string support to ImageQt
11 # 2013-11-13 fl: add support for Qt5 (aurelien.ballier@cyclonit.com)
12 #
13 # Copyright (c) 2006 by Secret Labs AB
14 # Copyright (c) 2006 by Fredrik Lundh
15 #
16 # See the README file for information on usage and redistribution.
17 #
18 
19 from . import Image
20 from ._util import isPath, py3
21 from io import BytesIO
22 import sys
23 
24 qt_versions = [
25     ['5', 'PyQt5'],
26     ['4', 'PyQt4'],
27     ['side', 'PySide']
28 ]
29 # If a version has already been imported, attempt it first
30 qt_versions.sort(key=lambda qt_version: qt_version[1] in sys.modules, reverse=True)
31 for qt_version, qt_module in qt_versions:
32     try:
33         if qt_module == 'PyQt5':
34             from PyQt5.QtGui import QImage, qRgba, QPixmap
35             from PyQt5.QtCore import QBuffer, QIODevice
36         elif qt_module == 'PyQt4':
37             from PyQt4.QtGui import QImage, qRgba, QPixmap
38             from PyQt4.QtCore import QBuffer, QIODevice
39         elif qt_module == 'PySide':
40             from PySide.QtGui import QImage, qRgba, QPixmap
41             from PySide.QtCore import QBuffer, QIODevice
42     except (ImportError, RuntimeError):
43         continue
44     qt_is_installed = True
45     break
46 else:
47     qt_is_installed = False
48     qt_version = None
49 
50 
51 def rgb(r, g, b, a=255):
52     """(Internal) Turns an RGB color into a Qt compatible color integer."""
53     # use qRgb to pack the colors, and then turn the resulting long
54     # into a negative integer with the same bitpattern.
55     return (qRgba(r, g, b, a) & 0xffffffff)
56 
57 
58 def fromqimage(im):
59     """
60     :param im: A PIL Image object, or a file name
61     (given either as Python string or a PyQt string object)
62     """
63     buffer = QBuffer()
64     buffer.open(QIODevice.ReadWrite)
65     # preserve alha channel with png
66     # otherwise ppm is more friendly with Image.open
67     if im.hasAlphaChannel():
68         im.save(buffer, 'png')
69     else:
70         im.save(buffer, 'ppm')
71 
72     b = BytesIO()
73     try:
74         b.write(buffer.data())
75     except TypeError:
76         # workaround for Python 2
77         b.write(str(buffer.data()))
78     buffer.close()
79     b.seek(0)
80 
81     return Image.open(b)
82 
83 
84 def fromqpixmap(im):
85     return fromqimage(im)
86     # buffer = QBuffer()
87     # buffer.open(QIODevice.ReadWrite)
88     # # im.save(buffer)
89     # # What if png doesn't support some image features like animation?
90     # im.save(buffer, 'ppm')
91     # bytes_io = BytesIO()
92     # bytes_io.write(buffer.data())
93     # buffer.close()
94     # bytes_io.seek(0)
95     # return Image.open(bytes_io)
96 
97 
98 def align8to32(bytes, width, mode):
99     """
100     converts each scanline of data from 8 bit to 32 bit aligned
101     """
102 
103     bits_per_pixel = {
104         '1': 1,
105         'L': 8,
106         'P': 8,
107     }[mode]
108 
109     # calculate bytes per line and the extra padding if needed
110     bits_per_line = bits_per_pixel * width
111     full_bytes_per_line, remaining_bits_per_line = divmod(bits_per_line, 8)
112     bytes_per_line = full_bytes_per_line + (1 if remaining_bits_per_line else 0)
113 
114     extra_padding = -bytes_per_line % 4
115 
116     # already 32 bit aligned by luck
117     if not extra_padding:
118         return bytes
119 
120     new_data = []
121     for i in range(len(bytes) // bytes_per_line):
122         new_data.append(bytes[i*bytes_per_line:(i+1)*bytes_per_line]
123                         + b'\x00' * extra_padding)
124 
125     return b''.join(new_data)
126 
127 
128 def _toqclass_helper(im):
129     data = None
130     colortable = None
131 
132     # handle filename, if given instead of image name
133     if hasattr(im, "toUtf8"):
134         # FIXME - is this really the best way to do this?
135         if py3:
136             im = str(im.toUtf8(), "utf-8")
137         else:
138             im = unicode(im.toUtf8(), "utf-8")
139     if isPath(im):
140         im = Image.open(im)
141 
142     if im.mode == "1":
143         format = QImage.Format_Mono
144     elif im.mode == "L":
145         format = QImage.Format_Indexed8
146         colortable = []
147         for i in range(256):
148             colortable.append(rgb(i, i, i))
149     elif im.mode == "P":
150         format = QImage.Format_Indexed8
151         colortable = []
152         palette = im.getpalette()
153         for i in range(0, len(palette), 3):
154             colortable.append(rgb(*palette[i:i+3]))
155     elif im.mode == "RGB":
156         data = im.tobytes("raw", "BGRX")
157         format = QImage.Format_RGB32
158     elif im.mode == "RGBA":
159         try:
160             data = im.tobytes("raw", "BGRA")
161         except SystemError:
162             # workaround for earlier versions
163             r, g, b, a = im.split()
164             im = Image.merge("RGBA", (b, g, r, a))
165         format = QImage.Format_ARGB32
166     else:
167         raise ValueError("unsupported image mode %r" % im.mode)
168 
169     __data = data or align8to32(im.tobytes(), im.size[0], im.mode)
170     return {
171         'data': __data, 'im': im, 'format': format, 'colortable': colortable
172     }
173 
174 
175 if qt_is_installed:
176     class ImageQt(QImage):
177 
178         def __init__(self, im):
179             """
180             An PIL image wrapper for Qt.  This is a subclass of PyQt's QImage
181             class.
182 
183             :param im: A PIL Image object, or a file name (given either as Python
184                 string or a PyQt string object).
185             """
186             im_data = _toqclass_helper(im)
187             # must keep a reference, or Qt will crash!
188             # All QImage constructors that take data operate on an existing
189             # buffer, so this buffer has to hang on for the life of the image.
190             # Fixes https://github.com/python-pillow/Pillow/issues/1370
191             self.__data = im_data['data']
192             QImage.__init__(self,
193                             self.__data, im_data['im'].size[0],
194                             im_data['im'].size[1], im_data['format'])
195             if im_data['colortable']:
196                 self.setColorTable(im_data['colortable'])
197 
198 
199 def toqimage(im):
200     return ImageQt(im)
201 
202 
203 def toqpixmap(im):
204     # # This doesn't work. For now using a dumb approach.
205     # im_data = _toqclass_helper(im)
206     # result = QPixmap(im_data['im'].size[0], im_data['im'].size[1])
207     # result.loadFromData(im_data['data'])
208     # Fix some strange bug that causes
209     if im.mode == 'RGB':
210         im = im.convert('RGBA')
211 
212     qimage = toqimage(im)
213     return QPixmap.fromImage(qimage)
214
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/PIL/ImageQt.py b/src/PIL/ImageQt.py
--- a/src/PIL/ImageQt.py
+++ b/src/PIL/ImageQt.py
@@ -23,6 +23,7 @@
 
 qt_versions = [
     ['5', 'PyQt5'],
+    ['side2', 'PySide2'],
     ['4', 'PyQt4'],
     ['side', 'PySide']
 ]
@@ -33,6 +34,9 @@
         if qt_module == 'PyQt5':
             from PyQt5.QtGui import QImage, qRgba, QPixmap
             from PyQt5.QtCore import QBuffer, QIODevice
+        elif qt_module == 'PySide2':
+            from PySide2.QtGui import QImage, qRgba, QPixmap
+            from PySide2.QtCore import QBuffer, QIODevice
         elif qt_module == 'PyQt4':
             from PyQt4.QtGui import QImage, qRgba, QPixmap
             from PyQt4.QtCore import QBuffer, QIODevice

{"golden_diff": "diff --git a/src/PIL/ImageQt.py b/src/PIL/ImageQt.py\n--- a/src/PIL/ImageQt.py\n+++ b/src/PIL/ImageQt.py\n@@ -23,6 +23,7 @@\n \n qt_versions = [\n     ['5', 'PyQt5'],\n+    ['side2', 'PySide2'],\n     ['4', 'PyQt4'],\n     ['side', 'PySide']\n ]\n@@ -33,6 +34,9 @@\n         if qt_module == 'PyQt5':\n             from PyQt5.QtGui import QImage, qRgba, QPixmap\n             from PyQt5.QtCore import QBuffer, QIODevice\n+        elif qt_module == 'PySide2':\n+            from PySide2.QtGui import QImage, qRgba, QPixmap\n+            from PySide2.QtCore import QBuffer, QIODevice\n         elif qt_module == 'PyQt4':\n             from PyQt4.QtGui import QImage, qRgba, QPixmap\n             from PyQt4.QtCore import QBuffer, QIODevice\n", "issue": "PySide2\nThe PySide2 (Qt for Python)[1] project developed by qt is now available even in pypi[2], I have always changed ImageQt.py manually, but I think it's time to add such changing to the official source\r\n\r\n[1] https://wiki.qt.io/Qt_for_Python\r\n[2] https://pypi.org/project/PySide2\n", "before_files": [{"content": "#\n# The Python Imaging Library.\n# $Id$\n#\n# a simple Qt image interface.\n#\n# history:\n# 2006-06-03 fl: created\n# 2006-06-04 fl: inherit from QImage instead of wrapping it\n# 2006-06-05 fl: removed toimage helper; move string support to ImageQt\n# 2013-11-13 fl: add support for Qt5 (aurelien.ballier@cyclonit.com)\n#\n# Copyright (c) 2006 by Secret Labs AB\n# Copyright (c) 2006 by Fredrik Lundh\n#\n# See the README file for information on usage and redistribution.\n#\n\nfrom . import Image\nfrom ._util import isPath, py3\nfrom io import BytesIO\nimport sys\n\nqt_versions = [\n    ['5', 'PyQt5'],\n    ['4', 'PyQt4'],\n    ['side', 'PySide']\n]\n# If a version has already been imported, attempt it first\nqt_versions.sort(key=lambda qt_version: qt_version[1] in sys.modules, reverse=True)\nfor qt_version, qt_module in qt_versions:\n    try:\n        if qt_module == 'PyQt5':\n            from PyQt5.QtGui import QImage, qRgba, QPixmap\n            from PyQt5.QtCore import QBuffer, QIODevice\n        elif qt_module == 'PyQt4':\n            from PyQt4.QtGui import QImage, qRgba, QPixmap\n            from PyQt4.QtCore import QBuffer, QIODevice\n        elif qt_module == 'PySide':\n            from PySide.QtGui import QImage, qRgba, QPixmap\n            from PySide.QtCore import QBuffer, QIODevice\n    except (ImportError, RuntimeError):\n        continue\n    qt_is_installed = True\n    break\nelse:\n    qt_is_installed = False\n    qt_version = None\n\n\ndef rgb(r, g, b, a=255):\n    \"\"\"(Internal) Turns an RGB color into a Qt compatible color integer.\"\"\"\n    # use qRgb to pack the colors, and then turn the resulting long\n    # into a negative integer with the same bitpattern.\n    return (qRgba(r, g, b, a) & 0xffffffff)\n\n\ndef fromqimage(im):\n    \"\"\"\n    :param im: A PIL Image object, or a file name\n    (given either as Python string or a PyQt string object)\n    \"\"\"\n    buffer = QBuffer()\n    buffer.open(QIODevice.ReadWrite)\n    # preserve alha channel with png\n    # otherwise ppm is more friendly with Image.open\n    if im.hasAlphaChannel():\n        im.save(buffer, 'png')\n    else:\n        im.save(buffer, 'ppm')\n\n    b = BytesIO()\n    try:\n        b.write(buffer.data())\n    except TypeError:\n        # workaround for Python 2\n        b.write(str(buffer.data()))\n    buffer.close()\n    b.seek(0)\n\n    return Image.open(b)\n\n\ndef fromqpixmap(im):\n    return fromqimage(im)\n    # buffer = QBuffer()\n    # buffer.open(QIODevice.ReadWrite)\n    # # im.save(buffer)\n    # # What if png doesn't support some image features like animation?\n    # im.save(buffer, 'ppm')\n    # bytes_io = BytesIO()\n    # bytes_io.write(buffer.data())\n    # buffer.close()\n    # bytes_io.seek(0)\n    # return Image.open(bytes_io)\n\n\ndef align8to32(bytes, width, mode):\n    \"\"\"\n    converts each scanline of data from 8 bit to 32 bit aligned\n    \"\"\"\n\n    bits_per_pixel = {\n        '1': 1,\n        'L': 8,\n        'P': 8,\n    }[mode]\n\n    # calculate bytes per line and the extra padding if needed\n    bits_per_line = bits_per_pixel * width\n    full_bytes_per_line, remaining_bits_per_line = divmod(bits_per_line, 8)\n    bytes_per_line = full_bytes_per_line + (1 if remaining_bits_per_line else 0)\n\n    extra_padding = -bytes_per_line % 4\n\n    # already 32 bit aligned by luck\n    if not extra_padding:\n        return bytes\n\n    new_data = []\n    for i in range(len(bytes) // bytes_per_line):\n        new_data.append(bytes[i*bytes_per_line:(i+1)*bytes_per_line]\n                        + b'\\x00' * extra_padding)\n\n    return b''.join(new_data)\n\n\ndef _toqclass_helper(im):\n    data = None\n    colortable = None\n\n    # handle filename, if given instead of image name\n    if hasattr(im, \"toUtf8\"):\n        # FIXME - is this really the best way to do this?\n        if py3:\n            im = str(im.toUtf8(), \"utf-8\")\n        else:\n            im = unicode(im.toUtf8(), \"utf-8\")\n    if isPath(im):\n        im = Image.open(im)\n\n    if im.mode == \"1\":\n        format = QImage.Format_Mono\n    elif im.mode == \"L\":\n        format = QImage.Format_Indexed8\n        colortable = []\n        for i in range(256):\n            colortable.append(rgb(i, i, i))\n    elif im.mode == \"P\":\n        format = QImage.Format_Indexed8\n        colortable = []\n        palette = im.getpalette()\n        for i in range(0, len(palette), 3):\n            colortable.append(rgb(*palette[i:i+3]))\n    elif im.mode == \"RGB\":\n        data = im.tobytes(\"raw\", \"BGRX\")\n        format = QImage.Format_RGB32\n    elif im.mode == \"RGBA\":\n        try:\n            data = im.tobytes(\"raw\", \"BGRA\")\n        except SystemError:\n            # workaround for earlier versions\n            r, g, b, a = im.split()\n            im = Image.merge(\"RGBA\", (b, g, r, a))\n        format = QImage.Format_ARGB32\n    else:\n        raise ValueError(\"unsupported image mode %r\" % im.mode)\n\n    __data = data or align8to32(im.tobytes(), im.size[0], im.mode)\n    return {\n        'data': __data, 'im': im, 'format': format, 'colortable': colortable\n    }\n\n\nif qt_is_installed:\n    class ImageQt(QImage):\n\n        def __init__(self, im):\n            \"\"\"\n            An PIL image wrapper for Qt.  This is a subclass of PyQt's QImage\n            class.\n\n            :param im: A PIL Image object, or a file name (given either as Python\n                string or a PyQt string object).\n            \"\"\"\n            im_data = _toqclass_helper(im)\n            # must keep a reference, or Qt will crash!\n            # All QImage constructors that take data operate on an existing\n            # buffer, so this buffer has to hang on for the life of the image.\n            # Fixes https://github.com/python-pillow/Pillow/issues/1370\n            self.__data = im_data['data']\n            QImage.__init__(self,\n                            self.__data, im_data['im'].size[0],\n                            im_data['im'].size[1], im_data['format'])\n            if im_data['colortable']:\n                self.setColorTable(im_data['colortable'])\n\n\ndef toqimage(im):\n    return ImageQt(im)\n\n\ndef toqpixmap(im):\n    # # This doesn't work. For now using a dumb approach.\n    # im_data = _toqclass_helper(im)\n    # result = QPixmap(im_data['im'].size[0], im_data['im'].size[1])\n    # result.loadFromData(im_data['data'])\n    # Fix some strange bug that causes\n    if im.mode == 'RGB':\n        im = im.convert('RGBA')\n\n    qimage = toqimage(im)\n    return QPixmap.fromImage(qimage)\n", "path": "src/PIL/ImageQt.py"}], "after_files": [{"content": "#\n# The Python Imaging Library.\n# $Id$\n#\n# a simple Qt image interface.\n#\n# history:\n# 2006-06-03 fl: created\n# 2006-06-04 fl: inherit from QImage instead of wrapping it\n# 2006-06-05 fl: removed toimage helper; move string support to ImageQt\n# 2013-11-13 fl: add support for Qt5 (aurelien.ballier@cyclonit.com)\n#\n# Copyright (c) 2006 by Secret Labs AB\n# Copyright (c) 2006 by Fredrik Lundh\n#\n# See the README file for information on usage and redistribution.\n#\n\nfrom . import Image\nfrom ._util import isPath, py3\nfrom io import BytesIO\nimport sys\n\nqt_versions = [\n    ['5', 'PyQt5'],\n    ['side2', 'PySide2'],\n    ['4', 'PyQt4'],\n    ['side', 'PySide']\n]\n# If a version has already been imported, attempt it first\nqt_versions.sort(key=lambda qt_version: qt_version[1] in sys.modules, reverse=True)\nfor qt_version, qt_module in qt_versions:\n    try:\n        if qt_module == 'PyQt5':\n            from PyQt5.QtGui import QImage, qRgba, QPixmap\n            from PyQt5.QtCore import QBuffer, QIODevice\n        elif qt_module == 'PySide2':\n            from PySide2.QtGui import QImage, qRgba, QPixmap\n            from PySide2.QtCore import QBuffer, QIODevice\n        elif qt_module == 'PyQt4':\n            from PyQt4.QtGui import QImage, qRgba, QPixmap\n            from PyQt4.QtCore import QBuffer, QIODevice\n        elif qt_module == 'PySide':\n            from PySide.QtGui import QImage, qRgba, QPixmap\n            from PySide.QtCore import QBuffer, QIODevice\n    except (ImportError, RuntimeError):\n        continue\n    qt_is_installed = True\n    break\nelse:\n    qt_is_installed = False\n    qt_version = None\n\n\ndef rgb(r, g, b, a=255):\n    \"\"\"(Internal) Turns an RGB color into a Qt compatible color integer.\"\"\"\n    # use qRgb to pack the colors, and then turn the resulting long\n    # into a negative integer with the same bitpattern.\n    return (qRgba(r, g, b, a) & 0xffffffff)\n\n\ndef fromqimage(im):\n    \"\"\"\n    :param im: A PIL Image object, or a file name\n    (given either as Python string or a PyQt string object)\n    \"\"\"\n    buffer = QBuffer()\n    buffer.open(QIODevice.ReadWrite)\n    # preserve alha channel with png\n    # otherwise ppm is more friendly with Image.open\n    if im.hasAlphaChannel():\n        im.save(buffer, 'png')\n    else:\n        im.save(buffer, 'ppm')\n\n    b = BytesIO()\n    try:\n        b.write(buffer.data())\n    except TypeError:\n        # workaround for Python 2\n        b.write(str(buffer.data()))\n    buffer.close()\n    b.seek(0)\n\n    return Image.open(b)\n\n\ndef fromqpixmap(im):\n    return fromqimage(im)\n    # buffer = QBuffer()\n    # buffer.open(QIODevice.ReadWrite)\n    # # im.save(buffer)\n    # # What if png doesn't support some image features like animation?\n    # im.save(buffer, 'ppm')\n    # bytes_io = BytesIO()\n    # bytes_io.write(buffer.data())\n    # buffer.close()\n    # bytes_io.seek(0)\n    # return Image.open(bytes_io)\n\n\ndef align8to32(bytes, width, mode):\n    \"\"\"\n    converts each scanline of data from 8 bit to 32 bit aligned\n    \"\"\"\n\n    bits_per_pixel = {\n        '1': 1,\n        'L': 8,\n        'P': 8,\n    }[mode]\n\n    # calculate bytes per line and the extra padding if needed\n    bits_per_line = bits_per_pixel * width\n    full_bytes_per_line, remaining_bits_per_line = divmod(bits_per_line, 8)\n    bytes_per_line = full_bytes_per_line + (1 if remaining_bits_per_line else 0)\n\n    extra_padding = -bytes_per_line % 4\n\n    # already 32 bit aligned by luck\n    if not extra_padding:\n        return bytes\n\n    new_data = []\n    for i in range(len(bytes) // bytes_per_line):\n        new_data.append(bytes[i*bytes_per_line:(i+1)*bytes_per_line]\n                        + b'\\x00' * extra_padding)\n\n    return b''.join(new_data)\n\n\ndef _toqclass_helper(im):\n    data = None\n    colortable = None\n\n    # handle filename, if given instead of image name\n    if hasattr(im, \"toUtf8\"):\n        # FIXME - is this really the best way to do this?\n        if py3:\n            im = str(im.toUtf8(), \"utf-8\")\n        else:\n            im = unicode(im.toUtf8(), \"utf-8\")\n    if isPath(im):\n        im = Image.open(im)\n\n    if im.mode == \"1\":\n        format = QImage.Format_Mono\n    elif im.mode == \"L\":\n        format = QImage.Format_Indexed8\n        colortable = []\n        for i in range(256):\n            colortable.append(rgb(i, i, i))\n    elif im.mode == \"P\":\n        format = QImage.Format_Indexed8\n        colortable = []\n        palette = im.getpalette()\n        for i in range(0, len(palette), 3):\n            colortable.append(rgb(*palette[i:i+3]))\n    elif im.mode == \"RGB\":\n        data = im.tobytes(\"raw\", \"BGRX\")\n        format = QImage.Format_RGB32\n    elif im.mode == \"RGBA\":\n        try:\n            data = im.tobytes(\"raw\", \"BGRA\")\n        except SystemError:\n            # workaround for earlier versions\n            r, g, b, a = im.split()\n            im = Image.merge(\"RGBA\", (b, g, r, a))\n        format = QImage.Format_ARGB32\n    else:\n        raise ValueError(\"unsupported image mode %r\" % im.mode)\n\n    __data = data or align8to32(im.tobytes(), im.size[0], im.mode)\n    return {\n        'data': __data, 'im': im, 'format': format, 'colortable': colortable\n    }\n\n\nif qt_is_installed:\n    class ImageQt(QImage):\n\n        def __init__(self, im):\n            \"\"\"\n            An PIL image wrapper for Qt.  This is a subclass of PyQt's QImage\n            class.\n\n            :param im: A PIL Image object, or a file name (given either as Python\n                string or a PyQt string object).\n            \"\"\"\n            im_data = _toqclass_helper(im)\n            # must keep a reference, or Qt will crash!\n            # All QImage constructors that take data operate on an existing\n            # buffer, so this buffer has to hang on for the life of the image.\n            # Fixes https://github.com/python-pillow/Pillow/issues/1370\n            self.__data = im_data['data']\n            QImage.__init__(self,\n                            self.__data, im_data['im'].size[0],\n                            im_data['im'].size[1], im_data['format'])\n            if im_data['colortable']:\n                self.setColorTable(im_data['colortable'])\n\n\ndef toqimage(im):\n    return ImageQt(im)\n\n\ndef toqpixmap(im):\n    # # This doesn't work. For now using a dumb approach.\n    # im_data = _toqclass_helper(im)\n    # result = QPixmap(im_data['im'].size[0], im_data['im'].size[1])\n    # result.loadFromData(im_data['data'])\n    # Fix some strange bug that causes\n    if im.mode == 'RGB':\n        im = im.convert('RGBA')\n\n    qimage = toqimage(im)\n    return QPixmap.fromImage(qimage)\n", "path": "src/PIL/ImageQt.py"}]}