[scribus] List of pictures
Gregory Pittman
gpittman at iglou.com
Wed Jun 1 14:56:30 UTC 2022
On 6/1/22 03:11, Rolf-Werner Eilert wrote:
> Good morning everyone!
>
> Is there a way to get a list of all pictures included in a document with filenames and their paths?
>
> Just had the "problem" that there is a document grown over the years with its own picture folder crammed with files which are no longer used. It is difficult to decide which files are in use and which files may be deleted from the folder.
>
> If I had a list, I could browse the folder and see it at once.
>
> I know that there are 2 tools for it in 1.5.8, and these tools are great. But instead of "Preview with filename" I would rather need something like "Path & filename & used" only. Something like a specialized file browser showing all picture files and which files are in use and which ones might be obsolete. This tool would of course have to be folder orientated, not document orientated.
>
Hi Rolf,
Here is a script I wrote to simply do what you ask. You run the script and it creates a file with a list of image filenames. As written, it will also extract the text. To eliminate the text, modify the script by commenting out the line
T.append(item[0]+'\t'+ strpage + '\n')
or 'alter the for item in d:' clause to:
for item in d:
if (item[1] == 2):
imgname = scribus.getImageFile(item[0])
T.append(item[0]+' ' + imgname + '\t' + strpage + '\n')
Greg
*****************Script begins************************
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File: extract_frames.py - Extracts the names of text and image frames,
# saving to a text file as a list with associated pages for each
#
# © 2017.02.09 Gregory Pittman
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
import scribus
def exportText(textfile):
page = 1
pagenum = scribus.pageCount()
T = []
content = []
T.append('Table of Contents \n\n')
while (page <= pagenum):
scribus.gotoPage(page)
d = scribus.getPageItems()
strpage = str(page)
for item in d:
if (item[1] == 4):
T.append(item[0]+'\t'+ strpage + '\n')
elif (item[1] == 2):
imgname = scribus.getImageFile(item[0])
T.append(item[0]+' ' + imgname + '\t' + strpage + '\n')
page +=1
output_file = open(textfile,'w')
output_file.writelines(T)
output_file.close()
endmessage = textfile + ' was created'
scribus.messageBox("Finished", endmessage, scribus.ICON_NONE, scribus.BUTTON_OK)
if scribus.haveDoc():
textfile = scribus.fileDialog('Enter name of file to save to', filter='Text Files (*.txt);;All Files (*)')
try:
if textfile == '':
raise Exception
exportText(textfile)
except Exception as e:
print (e)
else:
scribus.messageBox('Usage Error', 'You need a Document open', scribus.ICON_NONE, scribus.BUTTON_OK)
*********************Script Ends*******************************
More information about the scribus
mailing list