:param im: :type im: :param min_size: :type min_size: :param fill_color: :type fill_color: :return: :rtype:
(im, min_size=256, fill_color=(0, 0, 0, 0))
| 48 | |
| 49 | |
| 50 | def make_square(im, min_size=256, fill_color=(0, 0, 0, 0)): |
| 51 | """ |
| 52 | |
| 53 | :param im: |
| 54 | :type im: |
| 55 | :param min_size: |
| 56 | :type min_size: |
| 57 | :param fill_color: |
| 58 | :type fill_color: |
| 59 | :return: |
| 60 | :rtype: |
| 61 | """ |
| 62 | |
| 63 | x, y = im.size |
| 64 | size = max(min_size, x, y) |
| 65 | new_im = PIL.Image.new('RGBA', (size, size), fill_color) |
| 66 | new_im.paste(im, (int((size - x) / 2), int((size - y) / 2))) |
| 67 | return new_im |
| 68 | |
| 69 | |
| 70 | def convert_to_bytes(file_or_bytes, resize=None, fill=False): |