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
  • Наука та технологія

КОМЕНТАРІ • 21

  • @NotDefinedTech
    @NotDefinedTech  2 роки тому +3

    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/

  • @luuu_na35
    @luuu_na35 5 місяців тому

    10:13 I learned something even newer in something new, thanks!

  • @user-if1dj7fy2y
    @user-if1dj7fy2y 8 днів тому

    Bravo 👏👏 Lit 🌠 Impressive ❤
    Gratitude 🙏 for your satisfactory Work 🚀🌟🌱

  • @marcelohijo8167
    @marcelohijo8167 11 місяців тому

    it helps a lot!

  • @TheMetalMag
    @TheMetalMag Рік тому

    awesome thank you, I haven't started python yet but it will work I'm sure

    • @NotDefinedTech
      @NotDefinedTech  Рік тому

      Thank you! I hope it will be helpful for you.
      Good luck on your python journey!

  • @sergiocely-10
    @sergiocely-10 2 місяці тому

    Thank you, you are the best

  • @alexandermaschke7607
    @alexandermaschke7607 5 місяців тому

    Thanks for the great video. I would like to save the images in another folder. How can I change the output folder?

  • @ajayjoseph8722
    @ajayjoseph8722 Рік тому

    Thanks for the video. I was wondering if you have any tutorial to convert from webp to png or jpg or common format. Cheers

    • @NotDefinedTech
      @NotDefinedTech  Рік тому

      I do now! Thanks for the suggestion: ua-cam.com/video/LHqwhXBpb0E/v-deo.html

  • @Ibrahim_Rezzoug
    @Ibrahim_Rezzoug 2 роки тому +1

    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

    • @NotDefinedTech
      @NotDefinedTech  2 роки тому +1

      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, ""))

    • @Ibrahim_Rezzoug
      @Ibrahim_Rezzoug 2 роки тому

      ​@@NotDefinedTech Thank you SO MUCH it really helps me

  • @thangho7279
    @thangho7279 Рік тому

    Hi tomboy