Skip to main content

Import and resize pictures into amazon S3 storage

Project description

s3imageresizer

A python module to import and resize pictures into amazon S3 storage.

Synopsis

Typical usecase: fetch a bunch of image and generate thumbnails of various sizes for each of them, stored in S3.

from s3imageresizer import S3ImageResizer

from boto import s3
s3_conn = s3.connect_to_region(...)

# Initialize an S3ImageResizer:
i = S3ImageResizer(s3_conn)

urls = [
    'http://www.gokqsw.com/images/picture/picture-3.jpg',
    'http://www.gokqsw.com/images/picture/picture-4.jpg'
]

for url in urls:

    # Fetch image into memory
    i.fetch(url)

    # Apply the image EXIF rotation, if any
    i.orientate()

    # Resize this image, store it to S3 and return its url
    url1 = i.resize(
        width=200
    ).store(
        in_bucket='my-images',
        key_name='image-w200-jpg'
    )

    # Do it again, with a different size
    url2 = i.resize(
        height=400
    ).store(
        in_bucket='my-images',
        key_name='image-h200-jpg'
    )

More explanation

For method parameters, see the code (there isn't much of it ;-)

S3ImageResizer does all image operations in-memory, without writing images to disk.

S3ImageResizer uses PIL, has reasonable defaults for downsizing images and handle images with alpha channels nicely.

Installation

s3imageresizer requires Pillow, which in turn needs external libraries. On ubuntu, you would for example need:

sudo apt-get install libjpeg8 libjpeg8-dev libopenjpeg-dev

Then

pip install s3imageresizer

Source code

https://github.com/erwan-lemonnier/s3-image-resizer

Author

Erwan Lemonnier
github.com/pymacaron
github.com/erwan-lemonnier
www.linkedin.com/in/erwan-lemonnier/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

s3imageresizer-0.0.28.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file s3imageresizer-0.0.28.tar.gz.

File metadata

  • Download URL: s3imageresizer-0.0.28.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.5.0+

File hashes

Hashes for s3imageresizer-0.0.28.tar.gz
Algorithm Hash digest
SHA256 cada38b2e7dfba8ccf75c53530e349fa0c719c7711f46d67abe5c7695a736d47
MD5 bce28a1d7a1815db6d7114a88e4628d7
BLAKE2b-256 85420a48ff6091a8cbbcb8a3de5328369d4bee3ec4ff1a8c6addd668a792dd8a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page