def blob_image_jpg(request, nick, path): try: img = api.image_get(request.user, nick, path, format='jpg') if not img: return http.HttpResponseNotFound() content_type = "image/jpg" response = http.HttpResponse(content_type=content_type) response.write(img.content) return response except exception.ApiException, e: logging.info("exc %s", e) return http.HttpResponseForbidden()
def blob_image_jpg(request, nick, path): try: img = api.image_get(request.user, nick, path, format='jpg') if not img: return http.HttpResponseNotFound() match_pattern = AVATAR_RE.match(path) if match_pattern: image = images.Image(img.content) size = SIZES.get(match_pattern.group('size')) logging.info("Size should be: %s" % size) if size != image.height or size != image.width: image.resize(size, size) img_content = image.execute_transforms(images.JPEG) else: img_content = img.content content_type = "image/jpg" response = http.HttpResponse(content_type=content_type) response.write(img_content) return response except exception.ApiException, e: logging.info("exc %s", e) return http.HttpResponseForbidden()