Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 01-18-2015, 05:44 PM   #1
shotsky
Enthusiast
shotsky began at the beginning.
 
Posts: 39
Karma: 10
Join Date: Jul 2012
Device: none
Removing photos does not remove links to them

When using Reports to identify photos that are not wanted, and then deleting them, the photo disappears off disk, but the link remains in the epub. (For example, some ebooks have a bunch of graphics that are not wanted, and you can easily delete them in the Reports section. But the link stays in the epub.
So, if you run Calibre against the file to convert to another format, it renames all the photos based on how many photos remain in the file - which causes collisions, because the 'old' links have the 'old' names, and Calibre doesn't renumber the links that don't have photos on disk.
The result is that there is a mixture of old photo links to photos that don't exist and a group of new link names that reflect actual files on disk. Thus, you end up with photos being shuffled around.
There are a couple ways to solve this - In Sigil, if a photo is deleted using the reports image delete feature (which is the only one that lets you see the actual photos you might want to delete), when a photo is deleted, any links in the ebook leading to that photo should be deleted along with the photo.
The other solution would be for Calibre to use the provided photo names instead of renumbering them, but that's not likely to happen.
Since Calibre always numbers photos and assigns them from zero to however many photos are present (regardless of whether there are links to photos that don't exist) this collision problem remains.
The workaround is to manually delete all the placeholders in book view - not too bad for a small ebook, but a real pain of there are tons of them.
If I've missed a way to 'clean' those unwanted links out, please let me know.
Thanks,
John
shotsky is offline   Reply With Quote
Old 01-18-2015, 06:28 PM   #2
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,364
Karma: 203720150
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
There's no way to delete any kind of file (image or otherwise) that will result in all links to those files being automatically removed. The links have to be deleted manually, or with some sort of regex cleanup. Once all links are gone from the html files, the Delete Unused Media tool will show all images that are unused and can be deleted.

It's definitely something that a plugin could be created to do though. Have the plugin present a list of images to delete, and then parse all the xhtml and remove any img tags that refer to the deleted images.

Last edited by DiapDealer; 01-18-2015 at 06:37 PM.
DiapDealer is online now   Reply With Quote
Advert
Old 01-18-2015, 06:52 PM   #3
shotsky
Enthusiast
shotsky began at the beginning.
 
Posts: 39
Karma: 10
Join Date: Jul 2012
Device: none
When you delete a photo from within Sigil, it makes no sense to leave the links to it in the epub. That is my point. That link is totally unusable, and if you have 200 links to the deleted photo, you have to manually delete 200 links.
While it says it is deleting the photo from the ebook, if the link isn't deleted along with it, it is only half-done.
I don't see why a plugin should have to be created for something like that - there can't possibly be value in leaving links to a photo that has been deleted from the ebook.
shotsky is offline   Reply With Quote
Old 01-19-2015, 03:35 AM   #4
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,543
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by shotsky View Post
When you delete a photo from within Sigil, it makes no sense to leave the links to it in the epub.
It does if you intend to replace the photo with something else. Sure, in that case you'd use "replace" instead of "delete" (I'm guessing it's possible, I don't use Sigil, so I don't know if there's the option), but there's more than one way to skin a cat.

I would agree that it makes more sense to remove all links to a resource when the resource is deleted, and I would try to add the possibility if I were a developer. But then the problem is how to remove the links. Say you have something like this in the code:

Code:
<p>The landscape was amazing:</p>

<div><img src="landscape.png" alt=""/></div>

<p>it made my <img src="eyes.png" alt="eyes"/> water.</p>
(note the second image is inline.)

Now you remove both images, what should the code look like? Like this?

Code:
<p>The landscape was amazing:</p>

<div></div>

<p>it made my eyes water.</p>
(A program could be smart enough to use the "alt" text when removing the image, but should it remove the empty <div>? What if the "alt" text makes no sense without the image?)

And if anything is not perfect, you are left with no clue of where the image was supposed to be, so cleaning the result is going to be a little hell. It could be more practical to leave all references there, at least you can still search them and remove them with regex if you wish.
Jellby is offline   Reply With Quote
Old 01-19-2015, 12:30 PM   #5
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,487
Karma: 5703586
Join Date: Nov 2009
Device: many
Hi,

I agree with Jellby. I often will delete an image and later replace it with an improved version. I would not want the link to be removed nor would I want all of the "alt" text I wrote to go away either.

So I think DiapDealer's idea of either using a regular expression replacement or a plugin would be the best way to go. Regular Expression search and replacement can easily be done in Sigil right now and there are a number of Regular Expression experts here in this Forum and the Calibre forum can probably show you possible ways to accomplish what you want.

The plugin approach would take a bit more work, but perhaps someone will create a selectable toolbox of transformations plugin to make things easier. Something like this might be perfect example case for a tool like that. For example: It could use a regular expression to present a list of all of the img tags and allow the user to either select the ones to keep or the ones to remove.

KevinH
KevinH is offline   Reply With Quote
Advert
Old 01-19-2015, 01:06 PM   #6
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,912
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
I can see lots of reasons (many have been listed) to always do the 'remove image's as 2 steps.

(I also distrust always in full automatic anything. There are always exceptions )

BTW I prefer to remove the usage FIRST (image use report says 0 used) befor removal.
theducks is offline   Reply With Quote
Old 01-19-2015, 01:26 PM   #7
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,188
Karma: 144286760
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
The best idea would be an option to remove the link. Like being asked when the image is removed.
JSWolf is offline   Reply With Quote
Old 01-19-2015, 03:01 PM   #8
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,487
Karma: 5703586
Join Date: Nov 2009
Device: many
@JSWolf,

I disagree. That is clearly not the best idea in my opinion.

Again, this is something for a plugin or a specially tuned regular expression search and replace to do.

In general, this is not an issue for most users one way or the other. Most users do not have to remove 200+ images and their img tags while leaving selected others (and their img tags) untouched.

The Sigil interface is already busy/complicated enough. This is exactly the reason we decided to implement a plugin system. If you want that extra feature, then code it up as a "ImageandTagDeleter" plugin and you are good to go.
KevinH is offline   Reply With Quote
Old 02-01-2015, 08:55 AM   #9
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
Quote:
Originally Posted by KevinH View Post
The Sigil interface is already busy/complicated enough. This is exactly the reason we decided to implement a plugin system. If you want that extra feature, then code it up as a "ImageandTagDeleter" plugin and you are good to go.

I agree and that could even go as far as to provide you a list of images (to choose) from. So you chose and delete and it deletes. In addition to automatic delete any images that aren't present. This solves both issues and I agree with KevinH is really best suited for a plugin.
user_none is offline   Reply With Quote
Old 02-01-2015, 09:05 AM   #10
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,364
Karma: 203720150
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Definitely a plugin.

Automatic removal of links whenever an image was deleted could easily lead to disaster. I'm imagining a case where someone wants to replace a scene-break graphic that's littered throughout their finished-but-looking-for-a-little-polish ebook. Imagine their dismay when instead of simply deleting and adding the new scene-break image, they discover they have to recreate hundreds of image tags that went away.
DiapDealer is online now   Reply With Quote
Old 02-15-2015, 01:17 AM   #11
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,188
Karma: 144286760
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by DiapDealer View Post
Definitely a plugin.

Automatic removal of links whenever an image was deleted could easily lead to disaster. I'm imagining a case where someone wants to replace a scene-break graphic that's littered throughout their finished-but-looking-for-a-little-polish ebook. Imagine their dismay when instead of simply deleting and adding the new scene-break image, they discover they have to recreate hundreds of image tags that went away.
Make deleting the image links a right click option. So you right click on the image and select to delete image with links. Then you get an are you sure requester. No need for a plugin.
JSWolf is offline   Reply With Quote
Old 02-15-2015, 05:11 AM   #12
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,364
Karma: 203720150
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by JSWolf View Post
Make deleting the image links a right click option. So you right click on the image and select to delete image with links. Then you get an are you sure requester. No need for a plugin.
Write a plugin.
No need to modify Sigil's codebase to provide an "are you sure" button attached to a new context menu that's going to run code that a plugin could do just as well.
DiapDealer is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
removing links from text . rolgiati Sigil 14 01-18-2015 07:09 PM
Removing Arrow Links on EPUB book andy88 ePub 2 04-12-2013 06:29 AM
Removing social media links (and hyperlinks) benn44b Recipes 0 09-11-2011 04:46 PM
Apple removing links to Consumer Reports study from forums =X= News 96 08-08-2010 12:10 AM


All times are GMT -4. The time now is 05:13 PM.


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