Skip to content
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

Update batodl.py #6

Closed
wants to merge 1 commit into from
Closed

Update batodl.py #6

wants to merge 1 commit into from

Conversation

Godangel
Copy link

Use original image instead of converted jpeg. Detect correct extension.

Use original image instead of converted jpeg. Detect correct extension.
@AntonisTorb
Copy link
Owner

Hey there! Thanks for the suggestion and pull request! I'm afraid I cannot accept this PR though, as imghdr is deprecated and schedulled to be removed with the next version of Python, which is releasing next month.

Thankfully, what you want is easy, since the original file extension is part of the URL. I have updated this, so please check out da157d2 . In this commit I have changed the default behaviour to download all images in their original format, while also allowing for a different extension specified via command line argument. Feel free to check the README on how to use.

Great suggestion nevertheless, I have credited you in the README too, thank you!

Let me know if there's anything else!

@Godangel
Copy link
Author

I'm still suggesting not using Image.save() as it reencodes source image with poorer quality.

@AntonisTorb
Copy link
Owner

Oh I didn't know that, makes sense that it reencodes if pillow doesn't know what the original extension is.

Updated with commit 2f11f20 to write the bytes directly to the file if extension not specified or if specified extension matches the original.

Many thanks again, I learned something new!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants