![]() |
#1 |
Enthusiast
![]() Posts: 29
Karma: 10
Join Date: Oct 2015
Device: kobo
|
Images in Sigil (ePub)
I'm currently creating an illustrated ebook in Sigil, and have sort of worked out the html and css for the text and headings. Unfortunately, I'm completely stuck when it comes to the images.
My idea for the images, is for them to occupy the whole screen, either like the cover does, or else just as a whole page. I also want it to scale so that the aspect ratio remains the same. Thus, the image needs to scale to fit either the height or the width, whichever prevents the image from being cropped. As the images are contained within the chapter, I would prefer to NOT create a separate *.xhtml file for each image. I would also like to keep my inline css as basic and short as possible. (I would prefer to use the separate css file for this. If I try to use an inline <div> and <img> tags within the <body>, the image won't scale any smaller than the width of the original image. I just get scrollbars. When I try to use <svg> (which I know nothing about, but was copying instructions from the web) I end up with huge white bars above and below the image. In both cases, the image breaks itself to display over two pages. Could someone please help, by telling me, 1) what image format is best for epubs (jpg, png, svg, etc) 2) the best coding to make the images do what i want (and explain what each part means) I realise I am asking for a lot, but I really am stuck. ![]() ![]() ![]() ![]() ![]() My Html for inline images was: Code:
<div class="inline"> <img alt="" src="../Images/Image_04.png"/> </div> Code:
div.inline { height:99%; width:100%; page-break-inside:avoid; text-align:center; } div.inline img { display:inline-block; height:100%; margin:0 auto; } Last edited by bentleymaniac; 04-11-2016 at 11:29 PM. Reason: additional information |
![]() |
![]() |
![]() |
#2 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 557
Karma: 400004
Join Date: Feb 2009
Device: ONYX M96
|
I suggest you to use a different file for each image.
Remember: the height and width % are related to the parent of the DOM element where img is placed. This is not usually a problem for the width, because left and right edge are the same of the ebook screen. BUT this is a problem for the height, because the parent is the body, and the body height "begins" in first page of your chapter and ends in the last page of your chapter. So when you ask an height 90%, you are not talking about 90% of the page, but 90% of the body element, so 90% of the entire chapter! |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Enthusiast
![]() Posts: 29
Karma: 10
Join Date: Oct 2015
Device: kobo
|
Thanks. I may have accidentally come across a solution. I have yet to check it on an ereader, but it displays correctly (except for an extra page break after an image)
here's what I did: css Code:
p { font-family:"Book Antiqua"; src: url("../Fonts/BookAntiqua.TTF") format("truetype"); font-size:1.2em; text-indent:1.2em; margin-top:0px; margin-bottom:0px; text-align:justify; } p.ni { text-indent:0em; } div.inline { height:99%; width:100%; page-break-inside:avoid; text-align:center; } div.inline img { display:inline-block; height:auto; max-height:100%; width:auto; max-width:100%; margin:0 0; } Code:
<body> <p>Shoie, a thoughtful look on his face, turned the knob and walked into Alvin's bedroom. At least he <i>started</i> in. The act of opening the door triggered Alvin's Foolproof Burglar Alarm. A boxing glove packed with stones, mounted on a short section of two-by-four, came whipping through the air. It was powered by a screen-door spring. At the last moment Shoie suddenly remembered the Burglar Alarm — he'd been caught by it countless times before - and tried to duck. He was too late. The boxing glove struck him smack on the nose, and he went reeling back into Alvin's arms, while a loud bell clanged and the lights in the room flashed on and off.</p> <div class="inline"> <img alt="Image_02" src="../Images/Image_02.png"/> </div> <p>Daphne put her hand to her mouth and giggled. Her golden pigtails shook. "Shoie, I swear you'll <i>never</i> remember that dumb boxing glove that Alvin put up as a burglar alarm. I'll bet you've been hit by that thing fifty zillion times. Tomorrow you'll come up here and walk right into it again."</p> </body> ![]() any ways of making the code more efficient wouuld be handy. |
![]() |
![]() |
![]() |
#4 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 557
Karma: 400004
Join Date: Feb 2009
Device: ONYX M96
|
Yes, I forgot you want the image take all the space of the page, sorry.
Anyway the code is interesting: it seems ADE4 uses the height % referred to the page space instead body. Ibooks uses the body. |
![]() |
![]() |
![]() |
#5 | |
Enthusiast
![]() Posts: 29
Karma: 10
Join Date: Oct 2015
Device: kobo
|
Quote:
It seems to work in the latest Calibre reader, though. |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
mostly an observer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,518
Karma: 987654
Join Date: Dec 2012
Device: Kindle
|
I am skeptical that you can (or want to) fill the page, given that e-book readers come in various dimensions. The Fire tablet, for example, is skinnier than most e-ink computer screens.
I also usually put an image in its own file. I don't use SVG except for the cover, which Sigil does for me. I put an inline width instruction (usually 100%, with exceptions for the book colophon and for images of poor quality) but nothing for the height. This is the style: div.image { text-align:center; margin-bottom: 0.25em; } The bottom margin is to provide a bit of separation if there's a caption, as there usually is. |
![]() |
![]() |
![]() |
#7 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 557
Karma: 400004
Join Date: Feb 2009
Device: ONYX M96
|
Actually I suggest you to test with an ebook reader (adobe digital mobile). Your code give good results with Ibooks or ADE4, but I fear it will no work with real ebook reader (sorry today I forgot mine @home).
|
![]() |
![]() |
![]() |
#8 |
Enthusiast
![]() Posts: 29
Karma: 10
Join Date: Oct 2015
Device: kobo
|
no problem. I have two different types of Kobo reader, so I'll test on those when I finish the text editing.
|
![]() |
![]() |
![]() |
#9 |
Enthusiast
![]() Posts: 29
Karma: 10
Join Date: Oct 2015
Device: kobo
|
BTW, what's the usual formatting for html and css in an epub? I was taught to tab in for each command, but sigil and most ebooks I have looked at seem to write everything without tabs.
ie: The way I learned html/css Code:
<html> <body> <p class="..."> <span>...</span> </p> </body> </html> Code:
<html> <body> <p class="..."> <span>...</span> </p> </body> </html> Last edited by bentleymaniac; 04-12-2016 at 07:27 AM. |
![]() |
![]() |
![]() |
#10 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,439
Karma: 5703082
Join Date: Nov 2009
Device: many
|
For presentation of html on the reader it simply desn't matter. But if you have to manually edit the page, using indents helps to see the structure and that can help prevent mistakes when editing.
Sigil puts it exactly how it was provided to Sigil. You can use a reformat xhtml right click menu command to "pretty-print" format the page for you automatically if you want the indented version. KevinH |
![]() |
![]() |
![]() |
#11 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 557
Karma: 400004
Join Date: Feb 2009
Device: ONYX M96
|
|
![]() |
![]() |
![]() |
#12 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,884
Karma: 59840450
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#13 |
Enthusiast
![]() Posts: 29
Karma: 10
Join Date: Oct 2015
Device: kobo
|
So, I tried it on my Kobo Glo HD, and was majorly disappointed.
The images display at about a quarter the size of the screen, (1/2 width and 1/2 height), and they have massive page breaks before and after. What I'm really trying to do is have the image float slightly, so that it displays full screen (on every device) at the next page turn after a particular referenced point in the text. So, for instance, you have the description of an event happening, and the next page turn gives you the illustration full screen, then the next page turn back to text WITHOUT having three quarters of the page before the illustration blank because the image is forced in a particular spot in the text. Any ideas? I'm stumped. |
![]() |
![]() |
![]() |
#14 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 557
Karma: 400004
Join Date: Feb 2009
Device: ONYX M96
|
I think the max-height/max-width *could* be the problem. You ask to the picture to do not resize itself more than its pixel dimension. So if you open the book in a device with a high ppi density, the image will be "little".
Last edited by fbrzvnrnd; 04-14-2016 at 08:22 AM. |
![]() |
![]() |
![]() |
#15 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
The only foolproof method of having an image full page everytime is to have a seperate XHTML for each image. It is not ideal, far from it, but it is the only thing that works consistent. Also, if you want ensure that the aspect ratio is correct and that it is sized correctly on each device, regardless of the resolution, an SVG wrapper would be the best choice. That is also what most people use for a cover.
|
![]() |
![]() |
![]() |
Tags |
epub 3, help needed, sigil |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Images now showing in ePub after editing in Sigil or Calibre | postkast2929 | ePub | 44 | 04-21-2016 11:45 AM |
Can I use the code Sigil uses for Covers for other images? | rosshalde | Sigil | 4 | 12-23-2014 11:00 AM |
Copying Sigil Images Folder | EditorOne | Sigil | 5 | 06-08-2013 08:50 PM |
Images with Sigil | Gerlyn | ePub | 2 | 02-08-2012 01:05 PM |
Alreader not showing images after editing ePUB with Sigil | cerramadre | Sigil | 27 | 09-02-2011 10:24 PM |