Modify

Opened 13 years ago

Closed 13 years ago

#8974 closed defect (duplicate)

Size calculation extracted from SVG goes wrong

Reported by: Markus Kohler Owned by: Richard Liao
Priority: normal Component: TracImageSvgMacro
Severity: normal Keywords: size, units
Cc: Trac Release: 0.11

Description

The size is extracted from the svg file with regular expressions: w = re.search(width=["']([0-9]+\.?[0-9]?)(.*?)["'], svg) h = re.search(height=["']([0-9]+\.?[0-9]?)(.*?)["'], svg) resulting in a split (w_val, w_unit) = (8.2, 663in) instead of (w_val, w_unit) = (8.2663, in). The following change in the regexp repairs that defect: w = re.search(width=["']([0-9]+\.?[0-9]*)(.*?)["'], svg) h = re.search(height=["']([0-9]+\.?[0-9]*)(.*?)["'], svg)

Also there is a small bug which could make a difference if the horizontal and vertical units differ. Current code contains: w_val = int(math.ceil(float(w_val) * unitMapping[w_unit])) h_val = int(math.ceil(float(h_val) * unitMapping[w_unit])) while the second line should really be h_val = int(math.ceil(float(h_val) * unitMapping[h_unit]))

Attachments (0)

Change History (1)

comment:1 Changed 13 years ago by Markus Kohler

Resolution: duplicate
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Richard Liao.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.