![]() |
#1 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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 idea is to keep the original image size, so that it can scale well in different devices. Thanks |
![]() |
![]() |
![]() |
#2 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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 |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 972
Karma: 4999999
Join Date: Mar 2009
Location: Rosario, Argentina
Device: SONY PRS-T2, Kindle Paperwhite 11th gen
|
Quote:
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%;} ![]() ![]() |
|
![]() |
![]() |
![]() |
#4 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
![]() |
![]() |
![]() |
#5 | |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 972
Karma: 4999999
Join Date: Mar 2009
Location: Rosario, Argentina
Device: SONY PRS-T2, Kindle Paperwhite 11th gen
|
Quote:
Thanks again. |
|
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
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 |