Senseetive api : generate fragment with good ratio and not forced square.
--- 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
--- 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 = '<svg preserveAspectRatio="none" width="100px" height="100px" viewBox="' + frg.viewbox_square +'" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n\
+ image_file = default.kvstore.get_or_set(ImageFile(img.info.image_file))
+ ratio = int(100 * frg.ratio * image_file.ratio)
+ svg = '<svg preserveAspectRatio="none" width="' + str(ratio) + 'px" height="100px" viewBox="' + frg.viewbox +'" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n\
<defs>\n\
<clipPath id="fragment-clip">\n\
<path d="' + frg_path + '" />\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",