Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 07-06-2015, 07:53 AM   #1
Pablo
Guru
Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.
 
Pablo's Avatar
 
Posts: 972
Karma: 4999999
Join Date: Mar 2009
Location: Rosario, Argentina
Device: SONY PRS-T2, Kindle Paperwhite 11th gen
Scaling images with SVG wrapper

I'm formatting a book that includes some images for my Sony PRS-T2.

One of the images is 755(W) x 476(H) pixels. I want to scale this image so that it fits in the width of my screen (600 pixels), preserving the aspect ratio, using only the necessary screen space (not the whole screen), with a SVG wrapper:

Code:
 <div style="text-align: center; padding: 0pt; margin: 0pt;">
    <svg xmlns="http://www.w3.org/2000/svg" height="100%" preserveAspectRatio="xMidYMid meet" version="1.1" viewBox="0 0 755 476" width="100%" xmlns:xlink="http://www.w3.org/1999/xlink"><image height="476" width="755" xlink:href="../Images/fig03.gif" /></svg>
  </div>
The above does the job, but uses the whole screen. How should I modify it? Is it possible?

The idea is to keep the original image size, so that it can scale well in different devices.

Thanks
Pablo is offline   Reply With Quote
Old 07-07-2015, 01:35 AM   #2
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,346
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Your Height and Width settings are at 100%. If you want to take up less screen space you need to reduce those. However you are not going to get something that is exactly the number of pixels of your image.
Check out W3Schools SVG tutorial.

I'm not sure why you would need to use SVG though. I would simply insert the image using a div if you didn't want to ttake up the whole screen.

Code:
<div class="image1"><img alt="" src="../Images/example.jpg" /></div>

with CSS:
div.image1 {width:100%; max-width:755px} *add whatever styling you want
Turtle91 is offline   Reply With Quote
Advert
Old 07-07-2015, 07:30 AM   #3
Pablo
Guru
Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.
 
Pablo's Avatar
 
Posts: 972
Karma: 4999999
Join Date: Mar 2009
Location: Rosario, Argentina
Device: SONY PRS-T2, Kindle Paperwhite 11th gen
Quote:
Originally Posted by Turtle91 View Post
I'm not sure why you would need to use SVG though. I would simply insert the image using a div if you didn't want to take up the whole screen.
I don't know what I was thinking! After I saw your piece of code, I remembered using something similar some years ago in another book. I had a look inside and found this code:

Code:
div.im { 
	page-break-inside: avoid;
	margin: 0.2em 0 0.2em 0;
	text-indent: 0;
	text-align: center; }
div.im img { max-width:100%;}
I guess old age is catching up with me...

Pablo is offline   Reply With Quote
Old 07-07-2015, 11:44 AM   #4
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,346
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
no worries...it gets us all!

One minor difference in my code vs what you had:

I used {width:100%; max-width:755px} so that it takes up the whole screen on small displays, but is limited to the actual width of the image (755px) to prevent stretching and blurring on larger displays.
Turtle91 is offline   Reply With Quote
Old 07-07-2015, 01:44 PM   #5
Pablo
Guru
Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.Pablo ought to be getting tired of karma fortunes by now.
 
Pablo's Avatar
 
Posts: 972
Karma: 4999999
Join Date: Mar 2009
Location: Rosario, Argentina
Device: SONY PRS-T2, Kindle Paperwhite 11th gen
Quote:
Originally Posted by Turtle91 View Post
no worries...it gets us all!

One minor difference in my code vs what you had:

I used {width:100%; max-width:755px} so that it takes up the whole screen on small displays, but is limited to the actual width of the image (755px) to prevent stretching and blurring on larger displays.
That's a good one!

Thanks again.
Pablo is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Calibre svg cover wrapper for full-page images roger64 Editor 8 02-05-2015 08:02 PM
Svg wrapper and image resizing Nabodita ePub 24 05-02-2014 12:21 AM
Need Example SVG wrapper including caption GrannyGrump ePub 30 11-06-2013 03:20 AM
Adding an SVG Wrapper ghostyjack Sigil 16 06-15-2013 05:13 AM
An Issue about a SVG wrapper RbnJrg Kindle Formats 29 06-10-2013 08:11 PM


All times are GMT -4. The time now is 03:49 PM.


MobileRead.com is a privately owned, operated and funded community.