def publish_images(images, original, item): orig_file = get_file(original, item) for image in images: content_type = original['mimetype'] ok, output = crop_image(orig_file, image['file_name'], image['crop'], image['spec']) if ok: app.media.put(output, image['file_name'], content_type, _id=image['media'])
def create(self, docs, **kwargs): ids = [] for doc in docs: item = doc.pop('item') orig = item['renditions']['original'] orig_file = get_file(orig, item) no_custom_crops = doc.get('no_custom_crops', False) rendition_spec = get_renditions_spec( no_custom_crops=no_custom_crops) inserted = [] mimetype = item.get('mimetype', orig.get('mimetype', '/')) media_type, content_type = mimetype.split('/') renditions = generate_renditions(orig_file, orig['media'], inserted, media_type, mimetype, rendition_spec, app.media.url_for_media) doc['renditions'] = renditions ids.append(item['_id']) updates = {'renditions': item['renditions']} try: get_resource_service('archive').update(item['_id'], updates, item) except Exception as ex: logger.warning( 'failed to update the renditions for original item in archive' ) return ids
def create(self, docs, **kwargs): ids = [] for doc in docs: item = doc.pop('item') orig = item['renditions']['original'] orig_file = get_file(orig, item) rendition_spec = get_renditions_spec() inserted = [] media_type, content_type = item['mimetype'].split('/') renditions = generate_renditions(orig_file, orig['media'], inserted, media_type, item['mimetype'], rendition_spec, app.media.url_for_media) doc['renditions'] = renditions ids.append(item['_id']) return ids
def create(self, docs, **kwargs): ids = [] for doc in docs: item = doc.pop('item') orig = item['renditions']['original'] orig_file = get_file(orig, item) rendition_spec = get_renditions_spec() inserted = [] mimetype = item.get('mimetype', orig.get('mimetype', '/')) media_type, content_type = mimetype.split('/') renditions = generate_renditions(orig_file, orig['media'], inserted, media_type, mimetype, rendition_spec, app.media.url_for_media) doc['renditions'] = renditions ids.append(item['_id']) return ids
def create(self, docs, **kwargs): ids = [] for doc in docs: item = doc.pop("item") orig = item["renditions"]["original"] orig_file = get_file(orig, item) no_custom_crops = doc.get("no_custom_crops", False) rendition_spec = get_renditions_spec( no_custom_crops=no_custom_crops) inserted = [] mimetype = item.get("mimetype", orig.get("mimetype", "/")) media_type, content_type = mimetype.split("/") renditions = generate_renditions(orig_file, orig["media"], inserted, media_type, mimetype, rendition_spec, app.media.url_for_media) doc["renditions"] = renditions ids.append(item["_id"]) return ids