11-25-2019, 03:07 AM | #1 |
Banned
Posts: 168
Karma: 10010
Join Date: Oct 2018
Device: Tolino/PRS 650/Tablet
|
Coping with countless images
Hi,
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. So mi renamed one of the fleuron images to fleuron.jpg to be the master and change all other occurences to that file. I can walk trough all img elements, but unfortunetly the fleuron image is surrounded by a lot of different other images. In the preview its now not clear what picture has currently been caught by the regex. So this approach ends up in a lot of manual tasks. either by replacing by trial and if the wrong one has been marked rollback and try the next one. Or i use the "open picture in tab" to see if the current caught picture is the fleuron one and the reference can be set to the master fleuron. I tried another approach from the report but you cant rename or jump from the piture list to anything else - except deleting which is not helpful. If the preview would mark what has been marked in the code view - that would be an easy thing - but thats not available. Has someone another idea to speed this process up? Did i miss something? \\\/roni Last edited by Vroni; 11-25-2019 at 03:09 AM. Reason: typo |
11-25-2019, 04:58 AM | #2 | |
Grand Sorcerer
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
Spoiler:
It looks for images with a width of up to 50 pixels and changes the file name in the img src attribute to fleuron.jpg. If that code catches too many false positives, you might find KevinH's Access-Aide plugin helpful. Simply change the alt attribute of all fleurons to fleuron and then use a regex to change the file name of all images with a fleuron alt attribute. |
|
Advert | |
|
11-25-2019, 06:22 AM | #3 |
Banned
Posts: 168
Karma: 10010
Join Date: Oct 2018
Device: Tolino/PRS 650/Tablet
|
|
11-25-2019, 08:18 AM | #4 |
Grand Sorcerer
Posts: 27,552
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
|
11-25-2019, 08:31 AM | #5 |
Banned
Posts: 168
Karma: 10010
Join Date: Oct 2018
Device: Tolino/PRS 650/Tablet
|
Afraid can mean anxiety or fear.
So i was afraid that Python is the only option i have. And if you would look over my shoulder how slowly I am still in python... My first (and only) plugin took weeks |
Advert | |
|
11-25-2019, 08:44 AM | #6 |
Grand Sorcerer
Posts: 27,552
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Understood. I just figured HAVING an option as opposed to NOT having any might actually be comforting in some small way. Call me crazy, though.
|
11-25-2019, 09:37 AM | #7 | |
A Hairy Wizard
Posts: 3,099
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Quote:
eg: <div class="fleuron"><img alt="" src="../Images/01.jpg"/></div> <div class="fleuron"><img alt="" src="../Images/02.jpg"/></div> <div class="fleuron"><img alt="" src="../Images/15.jpg"/></div> search: <div class="fleuron"><img alt="" src="../Images/(.*?).jpg"/></div> replace: <div class="fleuron"><img alt="" src="../Images/fleuron.jpg"/></div> Then run a report and delete all images that are used 0 times. |
|
11-25-2019, 09:38 AM | #8 | |
Not Quite Dead
Posts: 194
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
|
Quote:
Not elegant, but sounds like much less effort than what you described. |
|
11-25-2019, 09:41 AM | #9 |
A Hairy Wizard
Posts: 3,099
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
An alternate - if a little more manually intensive - is to open the inspector. Hover the mouse over the different images in the inspector list and it will highlight the image in the preview pane. Then you can note which image name is the fleuron.
|
11-25-2019, 10:03 AM | #10 |
Wizard
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Let's say you're starting with images:
Code:
<img alt="" src="../Images/image001.png" /> [...] <img alt="" src="../Images/image098.png" /> <img alt="" src="../Images/image099.png" /> 1. Go into Tools > Reports > Image Files. 2. Look through the images, any that are duplicate fleurons: Right-Click > Delete From Book: 3. Once you get rid of all the fleurons, then return back to the main Sigil window. Open the Images folder, Shift-Click to highlight all images, Right-Click > Rename: 4. Rename to something completely different. Like "TempImages001". Now, all your surviving images will be named "TempImages001", "TempImages002": Code:
<img alt="" src="../Images/TempImages001.png" /> [...] <img alt="" src="../Images/image098.png" /> <img alt="" src="../Images/TempImages002.png" /> 5. Now you can use Regex to easily change all the old image code into "fleuron.png": Search: <img alt="" src="[^"]+image\d+\.png" /> Replace: <img alt="" src="../Images/fleuron.png" /> 6 (Optional). Now go through and give your surviving images all human-readable names. |
11-25-2019, 10:37 AM | #11 | |
Not Quite Dead
Posts: 194
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
|
Quote:
Last edited by Brett Merkey; 11-25-2019 at 11:07 AM. |
|
11-25-2019, 01:33 PM | #12 |
Guru
Posts: 692
Karma: 2180740
Join Date: Jan 2017
Location: Poland
Device: Misc
|
Additional question for OP – is the fleuron file identical? (has the same bytes, same size, etc.)
If so – I prepared the plugin (based on the idea of Doitsu and my other private plugin). I wanted to prepare it because I know that it may be useful to me in the future. I tested the plugin, but of course I recommend running it on a copy of the epub file. I know it can be optimized, but I wanted to make it work, not the perfect version. |
11-25-2019, 01:52 PM | #13 | |
Wizard
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
But great to have more tools in the toolbelt. |
|
11-25-2019, 03:03 PM | #14 | |
Banned
Posts: 168
Karma: 10010
Join Date: Oct 2018
Device: Tolino/PRS 650/Tablet
|
Quote:
Unfortunately not. They differ in pixel size like 400*80 or 401*80 or 402*79 and so on. And even if they have the same dimension, the picture itself is not exactly at the same position in the canvas - resulting in slightly different file size. |
|
11-25-2019, 03:54 PM | #15 | |
Well trained by Cats
Posts: 29,813
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Question: Coping books between libraries from a plugin | Terisa de morgan | Development | 2 | 10-20-2015 12:46 AM |
Duplicate checking while coping a library | Giuseppe Chillem | Calibre | 2 | 11-29-2011 08:58 AM |
Coping with old books | Iain | Workshop | 10 | 09-21-2010 09:12 AM |
Coping with capacitive buttons | Grimulkan | iRex | 7 | 05-29-2009 07:34 AM |
Coping / synching Plucker config between 2 PCs | FRAC | Reading and Management | 1 | 10-18-2005 05:21 PM |