Converts a locally-stored image file to a proper JPEG image file.
(file_name)
| 20 | |
| 21 | |
| 22 | def convert_image_file_to_jpg(file_name): |
| 23 | """ Converts a locally-stored image file to a proper JPEG image file. """ |
| 24 | infile = file_name |
| 25 | f, e = os.path.splitext(infile) |
| 26 | outfile = f + ".jpg" |
| 27 | if infile != outfile: |
| 28 | try: |
| 29 | with Image.open(infile) as image: |
| 30 | image.convert('RGB').save(outfile, "JPEG") |
| 31 | except IOError: |
| 32 | raise Exception("Cannot convert %s to jpg!" % file_name) |
| 33 | |
| 34 | |
| 35 | def load_image_from_url(image_url): |
no outgoing calls
no test coverage detected