Best way to scale images when compiling to ebook

User avatar
ighulme
Posts: 112
Joined: Sat Oct 25, 2014 12:55 pm
Platform: Mac, Win + iOS
Contact:

Sun Dec 03, 2017 10:43 am Post

I was just wondering how people set up their interior images for Kindle books.

I had started out setting a pixel width for interior images ( <$IMG:name;w=200> ), as I had read somewhere that percentages weren't supported (Is this correct?).

The problem is that on higher resolution devices the images begin to shrink on the page:

Image

To get around this I have been creating a full-width white background for my images. There is a setting (compile format --> Text Layout 'use 100% width for images wider than x-pts ) that means that now my images are always scaled to 100% width, so they now scale up and down with different devices. Perfect...

However. The only trouble with this is that the white background is now visible when the Kindle is set to Sepia or black:

Image

I think I will have to live with this, as I much prefer that the images scale, but I was just wondering how anybody else had approached this.

Is it there any way to use percentages for images instead of pts or pixels?


Many thanks,
Ian

p.s. When I'm web-developing I use:

width = x%
max-width = xpx

That way an image will always scale up or down until it reaches the maximum desired pixel size. Perfect.
I don't suppose this is supported in epub or Kindle formats is it?
I G HULME
The Heavenfield: http://www.heavenfield.com

User avatar
Bridey
Posts: 390
Joined: Wed Nov 22, 2017 2:24 pm
Platform: Mac

Sun Dec 03, 2017 3:05 pm Post

Use the image placeholder tag in the text, for example:

Code: Select all

<$img://Users/username/Desktop/scrivenerlogo.png>


And when compiling to ePub 3, edit the Formats > [Format Name] > CSS > Append Custom CSS Stylesheet to add:

Code: Select all

img { width: 100% !important; height: auto !important }


You can set the per cent number as you think best.

Does this work as you need it to?

User avatar
ighulme
Posts: 112
Joined: Sat Oct 25, 2014 12:55 pm
Platform: Mac, Win + iOS
Contact:

Sun Dec 03, 2017 4:17 pm Post

You can set the per cent number as you think best.

Ah, that works great for the smaller images - thanks! :)

Is there a way to add percentage sizes per image? I have some at 50% and some 100%.

It doesn't seem to work trying to add percentage sizes in the placeholder tags: <$Img:name;w=50%>

Many thanks,
Ian
I G HULME
The Heavenfield: http://www.heavenfield.com

User avatar
KB
Site Admin
Posts: 20716
Joined: Tue Jun 13, 2006 11:23 pm
Platform: Mac
Location: Truro, Cornwall
Contact:

Fri Dec 15, 2017 10:45 am Post

On this, there is currently no way to add a percentage size, because <$img> tags just get inserted into the text before export using the size tags. However, I have added an extra "ebook" tag for the next update. So, from now on, you could do this:

<$img:ImgName;w=400;ebook=50%>

In this example, the image will appear at 50% the width of the page on ebooks, but be 400pt across for all other formats. If you leave "ebook" out, then ebooks will use the same size as other formats. ("ebook" only works for ePub 3 and KF8, though.)
"You can't waltz in here, use my toaster, and start spouting universal truths without qualification."