mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
DOCX Input: Add support for presentational markup used to rotate or flip images
Note that it will only work if the output format supports CSS transforms, such as EPUB or AZW3
This commit is contained in:
parent
9417effbff
commit
bb21e82f75
@ -60,6 +60,26 @@ def get_image_properties(parent, XPath, get):
|
||||
title = docPr.get('title') or title
|
||||
if docPr.get('hidden', None) in {'true', 'on', '1'}:
|
||||
ans['display'] = 'none'
|
||||
transforms = []
|
||||
for graphic in XPath('./a:graphic')(parent):
|
||||
for xfrm in XPath('descendant::a:xfrm')(graphic):
|
||||
rot = xfrm.get('rot')
|
||||
if rot:
|
||||
try:
|
||||
rot = int(rot) / 60000
|
||||
except Exception:
|
||||
rot = None
|
||||
if rot:
|
||||
transforms.append(f'rotate({rot:g}deg)')
|
||||
fliph = xfrm.get('flipH')
|
||||
if fliph in ('1', 'true'):
|
||||
transforms.append('scaleX(-1)')
|
||||
flipv = xfrm.get('flipV')
|
||||
if flipv in ('1', 'true'):
|
||||
transforms.append('scaleY(-1)')
|
||||
|
||||
if transforms:
|
||||
ans['transform'] = ' '.join(transforms)
|
||||
|
||||
return ans, alt, title
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user