Compare commits

...

3 Commits

Author SHA1 Message Date
caribaud 5f8d8873b3 Warn about floating height/width and round them
Closes #8
2023-05-27 16:16:49 +02:00
caribaud 81be7d477b Prevent external CSS img interferences
Closes #10
2023-05-27 16:02:06 +02:00
caribaud 350dd4bb0e Fix width / height computation
Closes #9
2023-05-27 15:56:31 +02:00
3 changed files with 17 additions and 8 deletions

View File

@ -31,6 +31,11 @@
background-color: black;
}
/* Reset images style to avoid external CSS interfering */
#melpomene img {
all: initial;
}
#melpomene-content-frame {
position: relative;
flex: 1;

View File

@ -180,11 +180,11 @@ function getPagesCount() {
}
function pageOriginalHeight(pageNumber) {
return READER_PAGES.children[pageNumber - 1].height
return READER_PAGES.children[pageNumber - 1].naturalHeight
}
function pageOriginalWidth(pageNumber) {
return READER_PAGES.children[pageNumber - 1].width
return READER_PAGES.children[pageNumber - 1].naturalWidth
}
function readerFrameRatio() {
@ -192,15 +192,15 @@ function readerFrameRatio() {
}
function pageRatio(pageNumber) {
return READER_PAGES.children[pageNumber - 1].width / READER_PAGES.children[pageNumber - 1].height
return READER_PAGES.children[pageNumber - 1].naturalWidth / READER_PAGES.children[pageNumber - 1].naturalHeight
}
function pageMaxHeight(){
let max_height = 0
for (var i = 0; i < READER_PAGES.children.length; i++) {
if(READER_PAGES.children[i].height > max_height){
max_height = READER_PAGES.children[i].height
if(READER_PAGES.children[i].naturalHeight > max_height){
max_height = READER_PAGES.children[i].naturalHeight
}
}
@ -217,7 +217,7 @@ function previousPagesWidth(pageNumber) {
let totalWidth = 0
for (let idx = 0; idx < pageNumber - 1; idx++){
totalWidth = totalWidth + READER_PAGES.children[idx].width
totalWidth = totalWidth + READER_PAGES.children[idx].naturalWidth
}
return totalWidth

View File

@ -40,8 +40,12 @@ def extract_zooms(src_folder):
tree = ET.parse(svg_path)
root = tree.getroot()
zooms[idx]["width"] = int(root.get("width"))
zooms[idx]["height"] = int(root.get("height"))
if "." in root.get("width"):
print(f"WARNING: file {svg_path} has a floating width, it will be rounded", file=sys.stderr)
zooms[idx]["width"] = round(float(root.get("width")))
if "." in root.get("height"):
print(f"WARNING: file {svg_path} has a floating height, it will be rounded", file=sys.stderr)
zooms[idx]["height"] = round(float(root.get("height")))
for area in root.findall('.//{*}rect'):
zooms[idx]["zooms"].append([