(self, size_key)
size_key = target key size

        returns: Nothing
size_key = target key size
size_key = target key size
def make_size(self, size_key):
        """
        size_key = target key size

        returns: Nothing
        """
        rcache = self.rcache
        if not self.has_size(size_key):
            #make size from the next available largest size (so if there's a small_320 and you want small, generate it from next size up
            size_seq = IMAGE_SIZE_ORDERING.index(size_key)
            source_key = OBJECT_ORIGINAL
            target_size = (OBJECT_SIZE_MAP[size_key]['width'], OBJECT_SIZE_MAP[size_key]['height'])

            for source_size_key in IMAGE_SIZE_ORDERING[size_seq+1:]:
                if self.has_size(source_size_key):
                    source_key = source_size_key
                    break

            source_meta = CachedImageMeta.wrap(self.fetch_meta(OBJECT_ORIGINAL))

            if source_meta.width <= target_size[0]:
                rcache.set(self.stream_key(size_key), "")
                rcache.set(self.meta_key(size_key), simplejson.dumps(source_meta.to_json()))
            else:
                source_image_obj = self.fetch_image(source_key)

                target_image_obj = ImageOps.fit(source_image_obj, target_size, method=Image.BICUBIC)
                mime_ext = CachedImageMeta.get_extension(source_meta.content_type)

                #output to buffer
                target_handle = io.BytesIO()
                target_image_obj.save(target_handle, mime_ext)
                target_handle.seek(0)
                target_meta = CachedImageMeta.make_meta(target_handle, size_key, metadata={'content_type': source_meta.content_type})

                rcache.set(self.stream_key(size_key), target_handle.read())
                rcache.set(self.meta_key(size_key), simplejson.dumps(target_meta.to_json()))
def make_size ( self , size_key ) : rcache = self . rcache if not self . has_size ( size_key ) : #make size from the next available largest size (so if there's a small_320 and you want small, generate it from next size up size_seq = IMAGE_SIZE_ORDERING . index ( size_key ) source_key = OBJECT_ORIGINAL target_size = ( OBJECT_SIZE_MAP [ size_key ] [ 'width' ] , OBJECT_SIZE_MAP [ size_key ] [ 'height' ] ) for source_size_key in IMAGE_SIZE_ORDERING [ size_seq + 1 : ] : if self . has_size ( source_size_key ) : source_key = source_size_key break source_meta = CachedImageMeta . wrap ( self . fetch_meta ( OBJECT_ORIGINAL ) ) if source_meta . width <= target_size [ 0 ] : rcache . set ( self . stream_key ( size_key ) , "" ) rcache . set ( self . meta_key ( size_key ) , simplejson . dumps ( source_meta . to_json ( ) ) ) else : source_image_obj = self . fetch_image ( source_key ) target_image_obj = ImageOps . fit ( source_image_obj , target_size , method = Image . BICUBIC ) mime_ext = CachedImageMeta . get_extension ( source_meta . content_type ) #output to buffer target_handle = io . BytesIO ( ) target_image_obj . save ( target_handle , mime_ext ) target_handle . seek ( 0 ) target_meta = CachedImageMeta . make_meta ( target_handle , size_key , metadata = { 'content_type' : source_meta . content_type } ) rcache . set ( self . stream_key ( size_key ) , target_handle . read ( ) ) rcache . set ( self . meta_key ( size_key ) , simplejson . dumps ( target_meta . to_json ( ) ) )