# HG changeset patch # User cavaliet # Date 1363273881 -3600 # Node ID 0a75599363e93cf4134e6bcc91747aa4a2dda44a # Parent d88b2e258c628d7b5f6634feca8f81e13429158e Senseetive api : generate fragment with good ratio and not forced square. diff -r d88b2e258c62 -r 0a75599363e9 src/egonomy/models.py --- a/src/egonomy/models.py Thu Mar 14 15:23:35 2013 +0100 +++ b/src/egonomy/models.py Thu Mar 14 16:11:21 2013 +0100 @@ -114,7 +114,7 @@ @property def ratio(self): if not self.coordinates or self.coordinates=="MZ" or self.coordinates=="": - return 0 + return 1 _, _, vb_w, vb_h = self.get_viewbox_info() return vb_w/vb_h diff -r d88b2e258c62 -r 0a75599363e9 src/egonomy/views.py --- a/src/egonomy/views.py Thu Mar 14 15:23:35 2013 +0100 +++ b/src/egonomy/views.py Thu Mar 14 16:11:21 2013 +0100 @@ -13,12 +13,14 @@ from egonomy.search_indexes.paginator import SearchPaginator from egonomy.search_indexes.query import ModelRelatedSearchQuerySet from haystack.query import RelatedSearchQuerySet +from sorl.thumbnail import default +from sorl.thumbnail.images import ImageFile from unicodedata import normalize import json import os -import uuid import requests import subprocess +import uuid import logging logger = logging.getLogger(__name__) @@ -233,7 +235,9 @@ frg.coordinates = frg_path # We build the svg xml file = os.path.join(settings.MEDIA_ROOT, str(img.info.image_file)) - svg = '\n\ + image_file = default.kvstore.get_or_set(ImageFile(img.info.image_file)) + ratio = int(100 * frg.ratio * image_file.ratio) + svg = '\n\ \n\ \n\ \n\ @@ -254,6 +258,7 @@ out, err = p.communicate() if p.returncode!=0: return HttpResponse("Batik error : " + str(err)) + # The picture png is now created, we log into the senseetive api params = { "xaction":"sessions.create",