On Sunday, November 8, 2020 at 11:54:58 AM UTC-8, Gaël Princivalle wrote:
>
> > An interesting routine, but I just use PIL's thumbnail() method.  Could 
> you explain the advantages of your routine? 
> I've no idea. I've followed an example years ago and I'm still working 
> like that.
>
> Can you post here and example of how do you use the PIL's thumbnail() 
> method?
>

Villas is right, you do use thumbnail().  I got lost in the other 
calculations, which seem to be for sizing calcullations.  I just used a 
fixed size because that's what my application likes.  I do this standalone 
at the moment, but I do plan to replace my current of exec of easy 
thumbnail sooner or later, and avoid process tossing.  Also, ET can't do 
webp or some GIFs.  Pillow can read webp, but can't write it.  (Pillow can 
also read many videos, but doesn't know which frame you want for a 
thumbnail.)

The standalone code looks like:

      img = Image.open(os.path.join(curpath, f))
      img.thumbnail((200,200))
      if f.endswith(".jpg"):
         img.save(tf, "JPEG")
      elif f.endswith(".gif"):
         img.save(tf, "GIF")
      elif f.endswith(".png"):
         img.save(tf, "PNG")
      elif tfa.endswith(".jpg"):
         if img.mode != "RGB":
            print img.mode
            img =img.convert("RGB")
         img.save(tfa, "JPEG")


/dps

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/c0deb558-6816-4c20-ba27-67cb86e4c92co%40googlegroups.com.

Reply via email to