From 0613bca3bca77fbe26c49ee355998cb19ed718c3 Mon Sep 17 00:00:00 2001
From: celogeek <65178+celogeek@users.noreply.github.com>
Date: Fri, 13 Sep 2024 08:42:24 +0200
Subject: [PATCH] WIP

---
 internal/pkg/epubimage/epub_image.go        | 4 ++++
 internal/pkg/epubtemplates/blank.xhtml.tmpl | 1 -
 internal/pkg/epubtemplates/text.xhtml.tmpl  | 1 -
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/internal/pkg/epubimage/epub_image.go b/internal/pkg/epubimage/epub_image.go
index 6e8742c..330c24e 100644
--- a/internal/pkg/epubimage/epub_image.go
+++ b/internal/pkg/epubimage/epub_image.go
@@ -106,6 +106,10 @@ func (i EPUBImage) RelSize(viewWidth, viewHeight int) (relWidth, relHeight int)
 	w, h := viewWidth, viewHeight
 	srcw, srch := i.Width, i.Height
 
+	if srcw < w && srch < h {
+		return srcw, srch
+	}
+
 	if w <= 0 || h <= 0 || srcw <= 0 || srch <= 0 {
 		return
 	}
diff --git a/internal/pkg/epubtemplates/blank.xhtml.tmpl b/internal/pkg/epubtemplates/blank.xhtml.tmpl
index 0722dfc..88b3401 100644
--- a/internal/pkg/epubtemplates/blank.xhtml.tmpl
+++ b/internal/pkg/epubtemplates/blank.xhtml.tmpl
@@ -5,7 +5,6 @@
     <meta charset="utf-8" />
     <title>{{ .Title }}</title>
     <link href="style.css" type="text/css" rel="stylesheet"/>
-    <meta name="viewport" content="{{ .ViewPort }}"/>
   </head>
   <body>
   </body>
diff --git a/internal/pkg/epubtemplates/text.xhtml.tmpl b/internal/pkg/epubtemplates/text.xhtml.tmpl
index 21cea8f..6f2a349 100644
--- a/internal/pkg/epubtemplates/text.xhtml.tmpl
+++ b/internal/pkg/epubtemplates/text.xhtml.tmpl
@@ -5,7 +5,6 @@
     <meta charset="utf-8" />
     <title>{{ .Title }}</title>
     <link href="style.css" type="text/css" rel="stylesheet"/>
-    <meta name="viewport" content="{{ .ViewPort }}"/>
   </head>
   <body>
     <img src="../{{ .ImagePath }}" alt="{{ .Title }}" style="{{ .ImageStyle }}"/>