View Single Post
Old 11-28-2019, 08:53 PM   #29
AlanHK
Guru
AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.
 
AlanHK's Avatar
 
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
Quote:
Originally Posted by Vroni View Post
i have an epub with tons of pictures. Round about 50% is just a fleuron, and all of them are the same.

The filenames are all numbered in sequence, so there is no chance to identify a picture by its name.
I do this semi-manually using Irfanview (on Windows).
I've set Irfanview up as an "open with" program for images in Sigil.
So I open any image. Now I press "T" to open the thumbnail viewer, which shows all the images in the temp folder that Sigil has unzipped the images to. Then I can look at the names and images and see if there is a pattern.
If there is a sequence of filenames all the same image, I can select them in Sigil's file list and rename them to "f01" which will name them all in a sequence. Then back to Irfanview's thumbnails, press "F5" and it refreshes to show the new names. Keep doing that till I have all the fleurons renamed. Then I look at the images closely, see if they are identical, if not choose a good one to be the unique one, name it "fleuron".
Back in Sigil, do a regex s&r to convert all the f\d\d\.jpg to fleuron.jpg.

Tools/delete unused media files. Refresh the thumbnail view to see if I got them all.

While we're doing fleurons, I use Irfanview to clean them up. I have Photoshop, but Irfanview is simpler and faster.

Mostly the fleuron comes as a JPEG, often 24 bit, colour.
If it's linework, I rename the file to "Fleuron.gif", then "open with" Irfanview. It complains the format is wrong, I ignore that.
Image/Convert to greyscale.
If it needs it, "Sharpen".
Or Image/Colour corrections and adjust gamma and contrast.
Then "Image/Reduce colour depth". 4 colours is usually enough. If there are greys, 16. Or 2 colours if it's really simple, like a box. Just control-Z if it pixellates and use a higher number.
Now "Image/Palette/Edit palette" and make sure the "black" is pure black. (RGB 0 0 0), and white is (255 255 255).
And you can use F12 to get a very simple painting tools to tidy it up.

Now save (not "save as").
Since you've changed the format, in the OPF change
media-type="image/jpeg"/ to media-type="image/gif"/

-- I use GIF since it is very compact and lossless, and is compatible with Kindle; convert with Kindlegen and it is unchanged. PNGs get converted sometimes to GIF, or sometimes to JPEG, all larger and usually blurrier than the original.

If the fleuron image has a lot of tones, like photo, so better to keep as JPEG. You can use Irfanview's "Options/Lossless crop" to trim it without degrading the image. That will leave a backup image in the temp folder, but Sigil will discard it after you close and reopen the file as it is unmanifested. Or you can refresh Irfan's thumbnails and delete it there.

Unifying the dupes not only reduces the epub filesize by often half, it also make editing the file simpler, if you have 100 fewer files to deal with.

If there are several images I want to edit I will extract them and then reimport, and I can use Irfanview's batch operations to clean up groups of images (e.g., drop caps) en masse.

Last edited by AlanHK; 11-28-2019 at 11:54 PM.
AlanHK is offline   Reply With Quote