Automatic method to delete unused images that are linked

Post questions on how to use or achieve an effect in Inkscape.
Vectorator
Posts: 96
Joined: Tue Oct 21, 2014 1:40 pm
Location: Australia

Automatic method to delete unused images that are linked

Postby Vectorator » Thu Feb 19, 2015 1:06 pm

I was wondering if there is an automatic method to remove unused images that are relatively linked instead of embedded.

For example if I have my .svg file and then I have an image\ folder with images, but in a few months I delete some of the images from the svg file but not from the directory, is there some sort of trick to remove them automatically.

I know about embedding all then extracting all but I have found it can crash when working with a lot of large images.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Automatic method to delete unused images that are linked

Postby brynn » Thu Feb 19, 2015 1:24 pm

Do you mean you want a way to delete all the imported/linked images from an SVG file, all at once?

Or do you mean that you want them deleted from your hard drive, when they are deleted from the SVG file?

Vectorator
Posts: 96
Joined: Tue Oct 21, 2014 1:40 pm
Location: Australia

Re: Automatic method to delete unused images that are linked

Postby Vectorator » Thu Feb 19, 2015 1:26 pm

I mean to delete all the images in a folder that are not used in the svg file.

This is when the images in the svg file are linked instead of embedded.

So if I have

design.svg

and then

image1.png
image2.png
image3.png

All imported to the svg file via linking not embedding


but after a while I decide image2.png is obsolete and I delete it in the svg file but not the actual file in the folder, is there an auto trick to do this?


Ie. to tidy up a folder which has images that were once, but no longer used in an svg design.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Automatic method to delete unused images that are linked

Postby brynn » Thu Feb 19, 2015 1:41 pm

Not that I've ever heard of. You could check with the Extensions Repository http://wiki.inkscape.org/wiki/index.php ... Repository

Maybe this is another one of those "nice to have" extensions? Although to my way of thinking, that's completely outside of Inkscape. Do you know of other graphics programs that will do that kind of thing?

It would have to an optional feature, because not everyone wants an imported image deleted from their hard drive, just because they deleted it from an SVG file.

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Automatic method to delete unused images that are linked

Postby ragstian » Thu Feb 19, 2015 1:54 pm

Hi.

What you want can easily be coded in a small python script that;
first scan all your svg files in the directory for embedded images,
scan the directory for images,
delete the ones NOT found in the svg files.

A script like this can be "dangerous" and great care has to be taken to not delete something you might need at a later stage.
The "user" is the "user's" worst enemy. How many have typed "rm" using the wrong wildcard and deleted all files from the hard-drive?
Last edited by ragstian on Sat Feb 28, 2015 3:13 am, edited 1 time in total.
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

Vectorator
Posts: 96
Joined: Tue Oct 21, 2014 1:40 pm
Location: Australia

Re: Automatic method to delete unused images that are linked

Postby Vectorator » Thu Feb 19, 2015 2:14 pm

Ok thanks.

No I didn't expect any program would have this feature.

But it's good to know that it could be done if I could learn scripting for example.

Eventually I might build up 200+ images that were once used in the file but no longer used, in the folder where the linked images are stored. I would still have these saved in an original photos folder somewhere, but they wouldn't be needed in the inkscape linked images folder anymore. Although some could on day in the future, most wouldn't.

Of course if I bought a bluray burner I wouldn't have problems with backing up, even if I did leave all the unused images in the inkscape linked images folder.

Also I'm still designing my workflow.

See I will be taking photos of objects, cutting them out in gimp, import them into inkscape, putting them in front of backdrops individually and in combinations, sharpening them, applying shadow filters then exporting them with the backdrop as images. But often objects become obsolete and need to be removed.

I like to work with fairly high res (although png or tiff lzw compressed) images so I can export to high res print as well as web.

In Xara due to no relative linking and memory limits with 32bit version I had to optimise everything to lower res jpg which excluded using the same file for print (which I rarely if ever do, but might). But it was still very slow with several minutes saving time. So with linked images in inkscape it would be a fraction of a second saving time instead of many minutes, but unused images are not deleted automatically when saving. Although It probably would take a few years before enough unused images accumulated to not fit on a dvd for backup. I could probably just buy a bluray burner in a year or two and never worry about it. :) Since unused images won't have any effect on loading time.


Return to “Help with using Inkscape”