Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 01-23-2022, 09:03 PM   #1
landord01
Junior Member
landord01 began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Jan 2022
Device: Kobo Libra 2
convert imgage *px to max-height/width

Hi guys,

A book has all its images(over 1 hundred, each with it's own class) defined like:
Code:
.calibre10 {height: 256px, width: 200px}
I want to make them look like:
Code:
 .calibre10 {max-height: 100%, max-width: 90%}
I tried the "transform styles" tool provided by Calibre book editor. like:
change property height to max-height if it's greater than 10px
or
if the property height matches pattern like "height: /\d{2,3}[p][x]/gm" regexpression;
They don't work.

Anyone can help?
landord01 is offline   Reply With Quote
Old 01-24-2022, 12:07 PM   #2
lomkiri
Groupie
lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.
 
lomkiri's Avatar
 
Posts: 167
Karma: 1497966
Join Date: Jul 2021
Device: N/A
Quote:
Originally Posted by landord01 View Post
Code:
.calibre10 {height: 256px, width: 200px}
Do you mean ?:
Code:
.calibre10 {height: 256px; width: 200px}
(semicolon, not comma).
This should do the job, even if the file has been beautified:
Code:
search:
(height):\s*\d{2,}px;(\s*)(width):\s*\d{2,}px
replace:
max-\1: 100%;\2max-\3: 90%
(select: current file or all style files)
But:
It's probably better to put one of the two dimensions in auto.
Now, e-readers often tend to recognize better width than height. For landscape, it's obvious, width should be 100% . For portrait, it' not that easy, but I think that there is a sigil plugin that can calculate the right width in relation with the real size of the picture.

Last edited by lomkiri; 01-24-2022 at 02:17 PM.
lomkiri is offline   Reply With Quote
Advert
Old 01-27-2022, 03:02 AM   #3
landord01
Junior Member
landord01 began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Jan 2022
Device: Kobo Libra 2
Thank you, Lomkiri!
Yes, it should be semi-colon.
I tried searching on the style CSS file, it can't find any match.
My book is written in Traditional Chinese which is in vertical writing mode and is read from right to left. Height is more relevant on images.
I had another try of "transform style" tool, it works this time although images smaller than 10px are dismissed.
landord01 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image resizing issues while using max-height/max-width Detroa ePub 22 08-26-2020 06:17 PM
some basic questions about width/height/size angharad09 Workshop 1 08-18-2020 10:39 AM
Resizing images, retaining width-height rato, and only if necessary. Vanguard3000 Sigil 7 07-31-2015 10:43 AM
Flightcrew : is px for the height/width forbidden ? NicolasR Sigil 2 02-11-2011 03:51 AM
WIDTH and HEIGHT in <img> tags Pablo Sigil 3 06-10-2010 05:37 PM


All times are GMT -4. The time now is 02:11 AM.


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