round is better than square
This commit is contained in:
parent
b49558520a
commit
0acd66bee6
|
@ -11,7 +11,7 @@ def make_really_big(value, m):
|
||||||
v = str(value).strip()
|
v = str(value).strip()
|
||||||
if v[-2:] == 'px':
|
if v[-2:] == 'px':
|
||||||
no = int(value.replace("px", "")) * m
|
no = int(value.replace("px", "")) * m
|
||||||
return str(int(no)) + "px"
|
return str(int(round(no))) + "px"
|
||||||
else:
|
else:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ def parse_html(value, m):
|
||||||
matches = re.findall(p, value)
|
matches = re.findall(p, value)
|
||||||
for match in matches:
|
for match in matches:
|
||||||
val = int(match.replace("px", ""))
|
val = int(match.replace("px", ""))
|
||||||
new_val = val * m
|
new_val = int(round(val * m))
|
||||||
r = str(new_val) + "px"
|
r = str(new_val) + "px"
|
||||||
value = value.replace(match, r)
|
value = value.replace(match, r)
|
||||||
return value
|
return value
|
||||||
|
|
|
@ -627,7 +627,7 @@ def product_pdf(request):
|
||||||
width_mm = request.GET['width']
|
width_mm = request.GET['width']
|
||||||
else:
|
else:
|
||||||
width_mm = product.typ.print_width
|
width_mm = product.typ.print_width
|
||||||
height_mm = int(width_mm // product.typ.aspect_ratio)
|
height_mm = int(round(width_mm // product.typ.aspect_ratio))
|
||||||
pages = product.get_page_list()
|
pages = product.get_page_list()
|
||||||
m = product.get_print_multiplier(dpi)
|
m = product.get_print_multiplier(dpi)
|
||||||
url_list = []
|
url_list = []
|
||||||
|
@ -643,7 +643,7 @@ def article_pdf(request):
|
||||||
article = get_object_or_404_json(Article, pk=a_id)
|
article = get_object_or_404_json(Article, pk=a_id)
|
||||||
dpi = request.GET.get('dpi', 300)
|
dpi = request.GET.get('dpi', 300)
|
||||||
width_mm = request.GET.get('width', article.typ.print_width)
|
width_mm = request.GET.get('width', article.typ.print_width)
|
||||||
height_mm = int(width_mm // article.typ.aspect_ratio)
|
height_mm = int(round(width_mm // article.typ.aspect_ratio))
|
||||||
pages = Page.objects.filter(article=article).order_by('page_no')
|
pages = Page.objects.filter(article=article).order_by('page_no')
|
||||||
m = article.get_print_multiplier(dpi)
|
m = article.get_print_multiplier(dpi)
|
||||||
url = SITE_BASE + "/edit/view_article/%d/?m=%f" % (article.id, m)
|
url = SITE_BASE + "/edit/view_article/%d/?m=%f" % (article.id, m)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user