-
Notifications
You must be signed in to change notification settings - Fork 79
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
converts bad photo file extensions (supercedes 404/412) #691
Conversation
filename.split('.', 1)[1].lower() in current_app.config['PHOTO_REQUIRES_CONV'] | ||
|
||
|
||
def convert_image(filename): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this convert e.g. tiff and psd files to jpegs or just rename them? we can use imagemagick for the conversion, i think it should work for both tiff and psds (though we should test that, each are good candidates for unit tests)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, so I didn't realize imagemagick had a good python binding? Should I just use PIL?
(So there is no way to avoid the os.open/decompression bomb issue?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh right right, Pillow (Python 3 version of PIL) should do the trick! there's also a decent imagemagick API called wand
if you find that Pillow is lacking support for a filetype that you want to support.
But yeah I'm not seeing a way to convert these images without using something like Pillow (short of using a third-party service).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the Pillow docs for this method (https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.save),
"Saves this image under the given filename. If no format is specified, the format to use is determined from the filename extension, if possible."
So it would appear this is actually converting the files to the new format, not just changing the name.
However, maybe we should have a test for this if we don't already?
ee9e10e
to
62bbc7c
Compare
Hey @ssempervirens, I'm following up about the error message you got, I updated pytest to 5.2.2 in Also, since this PR is superseding #412, could you please close #412? (I checked and saw that you already closed #404.) Thanks! |
For what it's worth, I'm seeing the same thing as @McEileen. Namely, I was getting I think if we ran this through Travis CI again, the tests would probably pass. |
Resolves #369 and supercedes PRs #404 and #412. I made a real mess of this issue, and I figured a new branch is the cleanest fix since that was a while ago.
Status
WIP
Description of Changes
Fixes # 369.
Changes proposed in this pull request:
Notes for Deployment
Screenshots (if appropriate)
Tests and linting
I have rebased my changes on current
develop
pytests pass in the development environment on my local machine
Note: I get 'TypeError: attrib() got an unexpected keyword argument 'convert' when I
make test
. This seems to be an issue with the package attrs rather than anything I changed, but please let me know if this is not correct.flake8
checks pass