Пример #1
0
 def setUp(self):
     self.app = get_app()
     #declare testing state
     self.app.config["TESTING"] = True
     self.db, self.app.config["DATABASE"] = tempfile.mkstemp()
     
     #spawn test client
     self.client = self.app.test_client()
Пример #2
0
import os
import base64
from ctrleff import get_app
from util import random_string
import S3
import Image
import ExifTags
from local_config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,\
    S3_LOCATION, S3_BUCKET_NAME, S3_KEY_NAME
from S3 import S3Object
import time

MOBILE_OPTIMIZED_WIDTH = 480
MOBILE_OPTIMIZED_FILENAME_APPEND = "_optimized"
app = get_app()

def resize_img(img_path, basewidth=MOBILE_OPTIMIZED_WIDTH):
    img = Image.open(img_path)
    
    #rotate of exif info exists
    if not img._getexif() is None:
        found_exif = False
        for orientation in ExifTags.TAGS.keys() : 
            if ExifTags.TAGS[orientation]=='Orientation' :
                found_exif = True
                break
        exif=dict(img._getexif().items())
        
        if orientation in exif and found_exif:
            if exif[orientation] == 3: