mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
218de802ba
commit
1dacfc5709
@ -21,10 +21,17 @@ from calibre.utils.magick.draw import identify_data
|
|||||||
|
|
||||||
Image = namedtuple('Image', 'rid fname width height fmt item')
|
Image = namedtuple('Image', 'rid fname width height fmt item')
|
||||||
|
|
||||||
|
def as_num(x):
|
||||||
|
try:
|
||||||
|
return float(x)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return 0
|
||||||
|
|
||||||
def get_image_margins(style):
|
def get_image_margins(style):
|
||||||
ans = {}
|
ans = {}
|
||||||
for edge in 'Left Right Top Bottom'.split():
|
for edge in 'Left Right Top Bottom'.split():
|
||||||
val = getattr(style, 'padding' + edge) + getattr(style, 'margin' + edge)
|
val = as_num(getattr(style, 'padding' + edge)) + as_num(getattr(style, 'margin' + edge))
|
||||||
ans['dist' + edge[0]] = str(pt_to_emu(val))
|
ans['dist' + edge[0]] = str(pt_to_emu(val))
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user