Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- Creado con Spyder5
- Basado en: https://www.geeksforgeeks.org/python-pil-image-thumbnail-method/
- """
- from PIL import Image
- Original = input('Nombre de la inagen: ') # /ruta/a/la/imagen.(JPEG, PNG,)
- alto = int(input('Ingrese el alto: '))
- ancho = int(input('Ingrese el ancho: '))
- size = (alto, ancho)
- thumb = input('Nombre para el thumbnail: ') # /ruta/a/la/thumb_imagen.(JPEG, PNG,)
- def tnails():
- """
- Size − Required size
- Resample − Optional resampling filter. It can be one of these
- PIL.Image.NEAREST, PIL.Image.BILINEAR, PIL.Image.BICUBIC, or
- PIL.Image.LANCZOS. If omitted, it defaults to PIL.Image.BICUBIC.
- Returns None.
- """
- try:
- image = Image.open(Original)
- image.thumbnail(size)
- image.save(thumb)
- image1 = Image.open(thumb)
- image1.show()
- except IOError:
- pass
- tnails()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement