Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 04-13-2018, 02:44 PM   #1
stumped
Wizard
stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.
 
Posts: 3,305
Karma: 10259306
Join Date: May 2016
Device: kobo forma, Kobo Libra, Huawei media Tab, fire HD10, PW3 HDX8.9,
Question Any clever ways to replace image based dropcaps ?

I am reading a series of books that have what is, to me, a most annoying first character approach. Not a dropcap style but an annoying large single character image used for the first letter of each chapter. So I'm guessing there is a set of twenty six images in the epub -I have not looked closely at the code yet - and that they are used as IMG as needed in the html
What i'd like to do , just to my personal reading copies, is elegantly remove them, and substitute the relevant text character instead. The key word being elegant. I don't want to just brute force edit them away. That would be as unsatisfying as reading on, pretending they don't annoy me. And at fifty or more chapters per book it would be tedious
Any ideas ?
Maybe a compromise is to force each image to be about the size of a single character via a suitable CSS class on the IMG. That could maybe easily be regexed in?
Sometimes it helps to reverse the question, when inspiration is lacking. So how would one create and encode a set of first letter images, one per chapter, in some partially automated book production way? Why would any same person want to do that is a more philosopjical question maybe the publishers were bored monks in a previous lifetime.
stumped is offline   Reply With Quote
Old 04-13-2018, 04:03 PM   #2
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,249
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
If this was my book I'd definitely remove the images because first-letter images are useless if you use text-to-speech to 'read' books.

The approach I'd take would be:
1. Hope that the creator had used a useful naming convention for each image, e.g. first-letter-A.jpg, first-letter-B.jpg, etc. Then I'd construct a regex to cycle through them, find/replace one at a time (not replace all).

2. If that wasn't possible I'd still remove the images, but manually, the hard way.

3. For your compromise option, css something like the following might be acceptable:
Code:
img.drop {height:1em; width:auto}
jackie_w is offline   Reply With Quote
Old 04-13-2018, 05:31 PM   #3
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,358
Karma: 203720150
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by jackie_w View Post
2. If that wasn't possible I'd still remove the images, but manually, the hard way.
Ditto. I'd also check to see if the alt property had a clue before knuckling down and just getting it done.

"Elegant" is fine and dandy when you have something to work with. But I've often found that the search for elegant solutions with perfect one-pass regular expressions can sometimes take longer than just getting in a good rhythm and "doing it."
DiapDealer is offline   Reply With Quote
Old 04-13-2018, 06:00 PM   #4
exaltedwombat
Guru
exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.
 
Posts: 878
Karma: 2457540
Join Date: Nov 2011
Device: none
You know the answer to this. Look at the code. Maybe you can minimise each decorative character by simply modifying one line in the stylesheet. Or, as @jackie_w says, maybe there's a naming system that will let you turn:

<img alt="BigA" src="../Images/BigA.jpg"/><p>ardvark</p>

into:

<p>Aardvark</p>

with a simple bit of Regex. I hope so!
exaltedwombat is offline   Reply With Quote
Old 04-13-2018, 07:18 PM   #5
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
I agree with what everyone else said about the Regex. Only way you could get help is if is if you post code samples.

Maybe run it through the ScrambleEPUB plugin for Calibre:

https://www.mobileread.com/forums/sh...d.php?t=267998

IF they had human-readable file/class names (or proper alt data), this would make it easier. If not, you'll probably have to brute force them all.
Tex2002ans is offline   Reply With Quote
Old 04-13-2018, 07:27 PM   #6
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,313
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
Hopefully there IS some nicely named images...if not, you could just use sigil's renaming capability to give them good names...just right click on the image (or select multiple images) in the Book Browser/Images folder, then select 'rename'.

Expanding on the example above:

<img alt="BigA" src="../Images/BigA.jpg"/><p>ardvark</p>

Code:
search: <img alt=".*?" src="../Images/Big(.)\.jpg"/><p>(.*?)</p>
replace: <p class="firstpara">\1\2</p>

and include whatever styling you wish for the first paragraph of a chapter:
p.firstpara {yada yada}

Last edited by Turtle91; 04-13-2018 at 07:30 PM.
Turtle91 is offline   Reply With Quote
Old 04-14-2018, 01:36 AM   #7
stumped
Wizard
stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.
 
Posts: 3,305
Karma: 10259306
Join Date: May 2016
Device: kobo forma, Kobo Libra, Huawei media Tab, fire HD10, PW3 HDX8.9,
thanks all
text to speech - I never thought of that - excellent point
ok - code snippet time - this is for letter H
you sill see that the alt is empty, so no obvious way to mechanically know to put an H in there.
i will try squashing it via the dropcaps class code

.. checking the image names - there are images names containing ...L2 ...L25 but they don't contain alphabetical order letters, they must be created and letters assigned as needed, e.g. image 2 is W, image 3 is T

i have only examined one book so far
ok - code snippet time - this is for letter H
<h1 class="chapter1" id="c02">CHAPTER 2</h1>

<p class="nonindent"><span class="dropcaps1"><img alt="" src="../Images/Morg_9780345545657_epub_L05.jpg" class="calibre4"/></span>e’d
stumped is offline   Reply With Quote
Old 04-14-2018, 01:53 AM   #8
stumped
Wizard
stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.
 
Posts: 3,305
Karma: 10259306
Join Date: May 2016
Device: kobo forma, Kobo Libra, Huawei media Tab, fire HD10, PW3 HDX8.9,
Quote:
Originally Posted by jackie_w View Post
If this was my book I'd definitely remove the images because first-letter images are useless if you use text-to-speech to 'read' books.

The approach I'd take would be:
1. Hope that the creator had used a useful naming convention for each image, e.g. first-letter-A.jpg, first-letter-B.jpg, etc. Then I'd construct a regex to cycle through them, find/replace one at a time (not replace all).

2. If that wasn't possible I'd still remove the images, but manually, the hard way.

3. For your compromise option, css something like the following might be acceptable:
Code:
img.drop {height:1em; width:auto}
trying that compromise now - i see that I had previously zapped the dropcap class stylings i.e. left them empty..
no joy. see thumbnail


( aha but that was a good clue- there is another class in the code AFTER The IMG SRC bit, and putting height 1em in that class does work, I just now need to fix the image colour if possible. if that is an impae property then id have to do the full manual replace I guess- can't override it

<span class="dropcaps1"><img alt="" src="../Images/Morg_9780345545657_epub_L05.jpg" class="calibre4"/></span>

so setting class calibre 4 to
height: 1em;
width: 1em
made things much better - in Sigil on PC anyway - thanks
thumbnail shows how it was before doing that.
final step is send a revised copy to my reading tablet to see if moon+ is also well behaved with the change
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	165
Size:	4.1 KB
ID:	163476  

Last edited by stumped; 04-14-2018 at 02:01 AM.
stumped is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace image in ePub flyfisher33 ePub 0 01-31-2015 09:16 AM
Glo Kobo Glo: how to replace boot image elpaso Kobo Developer's Corner 12 05-08-2013 11:09 AM
inspect image properties /replace image cybmole Sigil 6 02-05-2013 12:46 PM
eReader for image based pdfs? space Which one should I buy? 0 07-29-2011 08:03 PM
Software for creating image-based PDFs 301verbs Workshop 2 06-13-2009 12:51 PM


All times are GMT -4. The time now is 01:51 PM.


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