Skip to content

Update batodl.py - #6

Closed
Godangel wants to merge 1 commit into
AntonisTorb:mainfrom
Godangel:patch-1
Closed

Godangel wants to merge 1 commit into
AntonisTorb:mainfrom
Godangel:patch-1

Conversation

@Godangel

Copy link
Copy Markdown

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

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

Copy link
Copy Markdown
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
Copy Markdown
Author

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

@AntonisTorb

Copy link
Copy Markdown
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