Optimized Images in Seconds | Python Image to Webp Converter
Вставка
- Опубліковано 13 чер 2022
- Webp format is an easy way to decrease your image load times on your website. Here's a python script to convert your images all at once, with the best settings for png and jpg.
For an explanation on getting the file extension using .split(), check out my article here:
notdefined.tech/blog/get-the-...
_______________
Get the code for this project here:
notdefined.tech/blog/auto-con...
NOTE: There's a bug in line 21 of this video's script. Change it to this is allow nested folders:
convert_to_webp(imagefile, os.path.join(root, ""))
_______________
Do more with what you have.
WHO AM I?
👨🏻💻 My name is Jess, I'm a designer turned web developer with a disability: Multiple Sclerosis. Technology helped save my career and my livelihood, so I want to pass along the knowledge.
LET'S CONNECT
✍️ Subscribe to the NDT blog - notdefined.tech/#/portal/signup
📸 Instagram - / notdefinedtech
FAVORITE HOSTING PLATFORM
🌊 DigitalOcean-Support the channel AND get $100 credit for 60 days with this referral link: m.do.co/c/5d4981832ae6 - Наука та технологія
Hey, all! There's a bug in line 21-huge thanks for Brahim Rezzoug for bringing this up. Change it to this so you can have folders within folders with images:
convert_to_webp(imagefile, os.path.join(root, ""))
Check out my article here to see it in place:
notdefined.tech/blog/auto-convert-all-images-to-webp-format-instant-load-time-improvement/
10:13 I learned something even newer in something new, thanks!
I'm double-glad, then! 😁
Bravo 👏👏 Lit 🌠 Impressive ❤
Gratitude 🙏 for your satisfactory Work 🚀🌟🌱
Thank you! 😁
it helps a lot!
Glad to hear it!
awesome thank you, I haven't started python yet but it will work I'm sure
Thank you! I hope it will be helpful for you.
Good luck on your python journey!
Thank you, you are the best
Glad to help!
Thanks for the great video. I would like to save the images in another folder. How can I change the output folder?
Thanks for the video. I was wondering if you have any tutorial to convert from webp to png or jpg or common format. Cheers
I do now! Thanks for the suggestion: ua-cam.com/video/LHqwhXBpb0E/v-deo.html
Hi, Thanks for this tutorial. It's great. If you have multiple folders containing jpg files and want python to convert each folder from jpg files to webp files ? For example,
you have folders A, B, and C. Each folder includes 1, 2, and 3 folders; each numbered folder has jpg files
how you deal with that
Hey! You helped me find a bug in my script, thank you so much! I wrote up an article with the fixed code here: notdefined.tech/blog/auto-convert-all-images-to-webp-format-instant-load-time-improvement/
The gist is that it should have already worked for you with nested folders, but line 21 in the original script throws errors if you had folders inside of folders.
If you change the last line of the convert_all function (line 21), it should fix it so you can now pass in folder A or another parent folder and convert all your image files in the 1, 2, 3 sub folders:
convert_to_webp(imagefile, os.path.join(root, ""))
@@NotDefinedTech Thank you SO MUCH it really helps me
Hi tomboy