thumbnail generation for nautilus via gimp
This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.
This is a read-only list on gimpusers.com so this discussion thread is read-only, too.
thumbnail generation for nautilus via gimp
Hello,
i got the idea to create a python script thats generate the thumbnails of unsupported images in nautilus using gimp. Implementing this in Gimp and in Nautilus.
I studied the commandline options ( -n, -a, -i, -d, -f, -s )of gimp and do not know if it is possible. Am i right i have to load and unload all the images of a directory to get gimp generating an thumbnail or is there a better way?
Thanx.
thumbnail generation for nautilus via gimp
Hi,
On Sat, 2007-12-01 at 20:45 +0100, Eckhard M. Jäger wrote:
i got the idea to create a python script thats generate the thumbnails of unsupported images in nautilus using gimp. Implementing this in Gimp and in Nautilus.
I studied the commandline options ( -n, -a, -i, -d, -f, -s )of gimp and do not know if it is possible. Am i right i have to load and unload
all the images of a directory to get gimp generating an thumbnail or is there a better way?
You can use the PDB function gimp-file-save-thumbnail(). See http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpfileops.html#gimp-file-save-thumbnail
Sven
thumbnail generation for nautilus via gimp
Hello Sven,
thanx for that. I tried something like
gimp -i -n -f -d -s -b '(gimp-file-save-thumbnail /path/to/image.psd)' -b '(gimp-quit 0)'
but i didn't get it work :(
This is what have done so far: http://my.opera.com/area42/blog/generating-thumbnails-using-gimp
-
|\/\/\/|
| |
| (O)(O) Bart.
C _) bart@neeneenee.de
| ,_/
| / - Ich bin nicht berechtigt Aushilfslehrer zu feuern -
/ \
http://www.neeneenee.de
Am Samstag, den 01.12.2007, 20:54 +0100 schrieb Sven Neumann:
Hi,
On Sat, 2007-12-01 at 20:45 +0100, Eckhard M. Jäger wrote:
i got the idea to create a python script thats generate the thumbnails of unsupported images in nautilus using gimp. Implementing this in Gimp and in Nautilus.
I studied the commandline options ( -n, -a, -i, -d, -f, -s )of gimp and do not know if it is possible. Am i right i have to load and unload
all the images of a directory to get gimp generating an thumbnail or is there a better way?You can use the PDB function gimp-file-save-thumbnail(). See http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpfileops.html#gimp-file-save-thumbnail
Sven
thumbnail generation for nautilus via gimp
Hi,
On Sun, 2007-12-02 at 12:56 +0100, Eckhard M. Jäger wrote:
thanx for that. I tried something like
gimp -i -n -f -d -s -b '(gimp-file-save-thumbnail /path/to/image.psd)' -b '(gimp-quit 0)'
but i didn't get it work :(
Have a look at the documentation again (hint: I gave you a link). Your call misses the ID of the image (that you need to obtain by opening it in GIMP beforehand). And your filename needs to be in parenthesis.
Sven
thumbnail generation for nautilus via gimp
Hello Sven,
thanks for the link and the help.
there is a thing that i don't understand, my script is opening the file
and so the thumbnail
is generated by Gimp automaticly when closing gimp.
I thought using gimp-file-save-thumbnail would be faster and uses less
memory then opening
the files like i did. But now i read the documentation and see to use
gimp-file-save-thumbnail
i have to open the file first to get the image ID.
So my question is: Is there an advantage using gimp-file-save-thumbnail?
-
|\/\/\/|
| |
| (O)(O) Bart.
C _) bart@neeneenee.de
| ,_/
| / - Ich bin nicht berechtigt Aushilfslehrer zu feuern -
/ \
http://www.neeneenee.de
Am Sonntag, den 02.12.2007, 15:30 +0100 schrieb Sven Neumann:
Hi,
On Sun, 2007-12-02 at 12:56 +0100, Eckhard M. Jäger wrote:
thanx for that. I tried something like
gimp -i -n -f -d -s -b '(gimp-file-save-thumbnail /path/to/image.psd)' -b '(gimp-quit 0)'
but i didn't get it work :(
Have a look at the documentation again (hint: I gave you a link). Your call misses the ID of the image (that you need to obtain by opening it in GIMP beforehand). And your filename needs to be in parenthesis.
Sven
thumbnail generation for nautilus via gimp
On Sun, 2007-12-02 at 21:25 +0100, Eckhard M. Jäger wrote:
I thought using gimp-file-save-thumbnail would be faster and uses less memory then opening the files like i did.
The thumbnails can in general only be generated by opening a file and processing it, to get the image data and scale it down.
An exception is that some file formats can include a thumbnail that's pregenerated, which might or might not be a useful size.
For most image formats you will probably find ImageMagick's mogrify or convert to be faster, or perhaps netpbm. But neither of those can read GIMP .xcf save files as far as I know.
Liam
thumbnail generation for nautilus via gimp
On Sun, 02 Dec 2007 21:25:09 +0100, Eckhard M. Jäger wrote:
Hello Sven,
thanks for the link and the help.
there is a thing that i don't understand, my script is opening the file and so the thumbnail
is generated by Gimp automaticly when closing gimp.I thought using gimp-file-save-thumbnail would be faster and uses less memory then opening
the files like i did. But now i read the documentation and see to use gimp-file-save-thumbnail
i have to open the file first to get the image ID.So my question is: Is there an advantage using gimp-file-save-thumbnail?
Hi,
As Liam suggested ImageMagick is a command line tool intended for precisely the sort of processing you are trying to do and will certainly be much lighter and faster than a full GUI image processing program like gimp. You could get your script to use gimp for (rare) cases like xcf format where you dont have an option.
http://www.imagemagick.org/script/index.php http://www.imagemagick.org/script/api.php#python
HTH
/gg
thumbnail generation for nautilus via gimp
Hi Eckhard,
On Dec 2, 2007 6:15 AM, Eckhard M. Jäger wrote:
Hello,
i got the idea to create a python script thats generate the thumbnails of unsupported images in nautilus using gimp. Implementing this in Gimp and in Nautilus.
I studied the commandline options ( -n, -a, -i, -d, -f, -s )of gimp and do not know if it is possible. Am i right i have to load and unload all the images of a directory to get gimp generating an thumbnail or is there a better way?
I recommend you to use gimp-console instead of gimp; The GUI is irrelevant to what you're doing.
Briefly, you need to:
1. Load the image
2. Generate the thumbnail
3. Delete the image from memory (using gimp-image-delete)
for each image in the list of images.
For a start, invoking gimp-console once for each image is fine. Later I suggest you run gimp-console only once, for greatly increased speed (make gimp's scripting loop over the files, rather than your scripting.). You could do this very easily if you can rely on gimp-python being installed on the users' machines, and use that instead of Script-Fu. (you can also write a loop in Script-fu, but I have very little idea HOW.)
thumbnail generation for nautilus via gimp
Hello,
thanx to all for the feedback and help.
@David
This sounds nice, i will check it out. I'm trying now to create a
automatic thumbnailer
( like http://wiki.ubuntuusers.de/OpenDocument_Thumbnails
http://wiki.ubuntuusers.de/_attachments/OpenDocument_Thumbnails/opendocument-thumbnailer
http://wiki.ubuntuusers.de/_attachments/OpenDocument_Thumbnails/opendocument.schemas )
and if it done i will write a small plugin called "Browse Images" that
will open Nautilus with the
directory of the opened image. If none image is loaded it will open the
home directory.
My Script generates at the moment only for PSD, RGB and XCF files
thumbnails, that i have
toch change too.
-
|\/\/\/|
| |
| (O)(O) Bart.
C _) bart@neeneenee.de
| ,_/
| / - Ich bin nicht berechtigt Aushilfslehrer zu feuern -
/ \
http://www.neeneenee.de
Am Montag, den 03.12.2007, 19:20 +1030 schrieb David Gowers:
Hi Eckhard,
On Dec 2, 2007 6:15 AM, Eckhard M. Jäger wrote:
Hello,
i got the idea to create a python script thats generate the thumbnails of unsupported images in nautilus using gimp. Implementing this in Gimp and in Nautilus.
I studied the commandline options ( -n, -a, -i, -d, -f, -s )of gimp and do not know if it is possible. Am i right i have to load and unload all the images of a directory to get gimp generating an thumbnail or is there a better way?
I recommend you to use gimp-console instead of gimp; The GUI is irrelevant to what you're doing.
Briefly, you need to: 1. Load the image
2. Generate the thumbnail
3. Delete the image from memory (using gimp-image-delete)for each image in the list of images.
For a start, invoking gimp-console once for each image is fine. Later I suggest you run gimp-console only once, for greatly increased speed (make gimp's scripting loop over the files, rather than your scripting.). You could do this very easily if you can rely on gimp-python being installed on the users' machines, and use that instead of Script-Fu. (you can also write a loop in Script-fu, but I have very little idea HOW.)
thumbnail generation for nautilus via gimp
Hi,
On Mon, 2007-12-03 at 07:55 +0100, gg@catking.net wrote:
As Liam suggested ImageMagick is a command line tool intended for precisely the sort of processing you are trying to do and will certainly be much lighter and faster than a full GUI image processing program like gimp.
In fact it turns out that ImageMagick is very often slower and needs more memory than GIMP. If you use 'gimp -i' then the UI is not loaded and the gimp-console binary doesn't even have the UI linked in.
Sven
thumbnail generation for nautilus via gimp
Hello,
i started writing the internal Gimp script for looping over the images. My code is so far the simple:
# -*- coding: utf-8 -*-
from gimpfu import *
import os
import os.path
def python_thumbnailer(this_image, this_path): a = this_path
register(
"python-fu-thumbnailer",
"Generating thumbnails",
"Generating thumbnails for Nautilus via Gimp",
"Eckhard M. Jaeger",
"Eckhard M. Jaeger",
"2007",
"/Xtns/Nautilus Thumbnailer...",
"",
[
(PF_STRING, "this_path", "Directory Path", ""),
],
[],
python_thumbnailer)
main()
this script is copied into ~/.gimp-2.4/plug-ins but didn't appear
anywhere :(
I can't find the bug, please can somebody help me. Thanx.
-
|\/\/\/|
| |
| (O)(O) Bart.
C _) bart@neeneenee.de
| ,_/
| / - Ich bin nicht berechtigt Aushilfslehrer zu feuern -
/ \
http://www.neeneenee.de
Am Montag, den 03.12.2007, 19:20 +1030 schrieb David Gowers:
Hi Eckhard,
On Dec 2, 2007 6:15 AM, Eckhard M. Jäger wrote:
Hello,
i got the idea to create a python script thats generate the thumbnails of unsupported images in nautilus using gimp. Implementing this in Gimp and in Nautilus.
I studied the commandline options ( -n, -a, -i, -d, -f, -s )of gimp and do not know if it is possible. Am i right i have to load and unload all the images of a directory to get gimp generating an thumbnail or is there a better way?
I recommend you to use gimp-console instead of gimp; The GUI is irrelevant to what you're doing.
Briefly, you need to: 1. Load the image
2. Generate the thumbnail
3. Delete the image from memory (using gimp-image-delete)for each image in the list of images.
For a start, invoking gimp-console once for each image is fine. Later I suggest you run gimp-console only once, for greatly increased speed (make gimp's scripting loop over the files, rather than your scripting.). You could do this very easily if you can rely on gimp-python being installed on the users' machines, and use that instead of Script-Fu. (you can also write a loop in Script-fu, but I have very little idea HOW.)
thumbnail generation for nautilus via gimp
On Tue, 04 Dec 2007 21:24:56 +0100 "Eckhard M." Jäger wrote:
Hello,
i started writing the internal Gimp script for looping over the images. My code is so far the simple:
# -*- coding: utf-8 -*-
from gimpfu import * import os
import os.pathdef python_thumbnailer(this_image, this_path): a = this_path
register(
"python-fu-thumbnailer",
"Generating thumbnails",
"Generating thumbnails for Nautilus via Gimp", "Eckhard M. Jaeger",
"Eckhard M. Jaeger",
"2007",
"/Xtns/Nautilus Thumbnailer...",
"",
[
(PF_STRING, "this_path", "Directory Path", ""), ],
[],
python_thumbnailer)main()
this script is copied into ~/.gimp-2.4/plug-ins but didn't appear anywhere :(
I can't find the bug, please can somebody help me. Thanx.
I don't know, but did you get any error messages when you started the Gimp from the command line?
If it uses python, do you need to call python #!/usr/bin/python?
Does it have the right permissions?
When I add those corrections, I get the menu item
Owen
thumbnail generation for nautilus via gimp
Hello,
thanks for the feedback but other python plugins did work like Pylomo http://registry.gimp.org/plugin?id=10976 which didn't has a header starting with #!/usr/bin/python .
I'm using Ubuntu 7.10 and Gimpo 2.42 ( http://www.getdeb.net/app.php?name=Gimp ).
-
|\/\/\/|
| |
| (O)(O) Bart.
C _) bart@neeneenee.de
| ,_/
| / - Ich bin nicht berechtigt Aushilfslehrer zu feuern -
/ \
http://www.neeneenee.de
Am Mittwoch, den 05.12.2007, 10:14 +1100 schrieb Owen:
On Tue, 04 Dec 2007 21:24:56 +0100 "Eckhard M." Jäger wrote:
Hello,
i started writing the internal Gimp script for looping over the images. My code is so far the simple:
# -*- coding: utf-8 -*-
from gimpfu import * import os
import os.pathdef python_thumbnailer(this_image, this_path): a = this_path
register(
"python-fu-thumbnailer",
"Generating thumbnails",
"Generating thumbnails for Nautilus via Gimp", "Eckhard M. Jaeger",
"Eckhard M. Jaeger",
"2007",
"/Xtns/Nautilus Thumbnailer...",
"",
[
(PF_STRING, "this_path", "Directory Path", ""), ],
[],
python_thumbnailer)main()
this script is copied into ~/.gimp-2.4/plug-ins but didn't appear anywhere :(
I can't find the bug, please can somebody help me. Thanx.I don't know, but did you get any error messages when you started the Gimp from the command line?
If it uses python, do you need to call python #!/usr/bin/python?
Does it have the right permissions?
When I add those corrections, I get the menu item
Owen
thumbnail generation for nautilus via gimp
Hello David,
thanks for the feedback. the script is well formed. The indention get
lost pasting into
Evolution mailer.
I didn't get any error or message on the concole :(
-
|\/\/\/|
| |
| (O)(O) Bart.
C _) bart@neeneenee.de
| ,_/
| / - Ich bin nicht berechtigt Aushilfslehrer zu feuern -
/ \
http://www.neeneenee.de
Am Mittwoch, den 05.12.2007, 09:17 +1030 schrieb David Gowers:
Hi Eckhard,
On Dec 5, 2007 6:54 AM, Eckhard M. Jäger wrote:
Hello,
i started writing the internal Gimp script for looping over the images. My code is so far the simple:
# -*- coding: utf-8 -*-
from gimpfu import * import os
import os.pathdef python_thumbnailer(this_image, this_path): a = this_path
If there is really no indentation here, this will cause an IndentationError. You can see GIMP reports such errors on the terminal it was run from; so while you are debugging I recommend you run GIMP from an xterm.
register(
"python-fu-thumbnailer",
"Generating thumbnails",
"Generating thumbnails for Nautilus via Gimp", "Eckhard M. Jaeger",
"Eckhard M. Jaeger",
"2007",
"/Xtns/Nautilus Thumbnailer...",
"",
[
(PF_STRING, "this_path", "Directory Path", ""), ],
[],
python_thumbnailer)main()
this script is copied into ~/.gimp-2.4/plug-ins but didn't appear anywhere :(
I can't find the bug, please can somebody help me. Thanx.- |\/\/\/|
| |
| (O)(O) Bart.
C _) bart@neeneenee.de
| ,_/
| / - Ich bin nicht berechtigt Aushilfslehrer zu feuern - / \
http://www.neeneenee.deAm Montag, den 03.12.2007, 19:20 +1030 schrieb David Gowers: Hi Eckhard,
On Dec 2, 2007 6:15 AM, Eckhard M. Jäger wrote:
Hello,
i got the idea to create a python script thats generate the thumbnails of unsupported images in nautilus using gimp. Implementing this in Gimp and in Nautilus.
I studied the commandline options ( -n, -a, -i, -d, -f, -s )of gimp and do not know if it is possible. Am i right i have to load and unload all the images of a directory to get gimp generating an thumbnail or is there a better way?
I recommend you to use gimp-console instead of gimp; The GUI is irrelevant to what you're doing.
Briefly, you need to: 1. Load the image
2. Generate the thumbnail
3. Delete the image from memory (using gimp-image-delete)for each image in the list of images.
For a start, invoking gimp-console once for each image is fine. Later I suggest you run gimp-console only once, for greatly increased speed (make gimp's scripting loop over the files, rather than your scripting.). You could do this very easily if you can rely on gimp-python being installed on the users' machines, and use that instead of Script-Fu. (you can also write a loop in Script-fu, but I have very little idea HOW.)
thumbnail generation for nautilus via gimp
Hello,
i found the problem why the script doesn't showed up, it needs the file
permission "Exexcute".
Do not know why, i have written exporters for Blender and plugins for
gEdit both in Python but
they didn't need the permission "Exexcute".
Ok, i'm new to Python Gimp plugins.
-
|\/\/\/|
| |
| (O)(O) Bart.
C _) bart@neeneenee.de
| ,_/
| / - Ich bin nicht berechtigt Aushilfslehrer zu feuern -
/ \
http://www.neeneenee.de
Am Mittwoch, den 05.12.2007, 10:14 +1100 schrieb Owen:
On Tue, 04 Dec 2007 21:24:56 +0100 "Eckhard M." Jäger wrote:
Hello,
i started writing the internal Gimp script for looping over the images. My code is so far the simple:
# -*- coding: utf-8 -*-
from gimpfu import * import os
import os.pathdef python_thumbnailer(this_image, this_path): a = this_path
register(
"python-fu-thumbnailer",
"Generating thumbnails",
"Generating thumbnails for Nautilus via Gimp", "Eckhard M. Jaeger",
"Eckhard M. Jaeger",
"2007",
"/Xtns/Nautilus Thumbnailer...",
"",
[
(PF_STRING, "this_path", "Directory Path", ""), ],
[],
python_thumbnailer)main()
this script is copied into ~/.gimp-2.4/plug-ins but didn't appear anywhere :(
I can't find the bug, please can somebody help me. Thanx.I don't know, but did you get any error messages when you started the Gimp from the command line?
If it uses python, do you need to call python #!/usr/bin/python?
Does it have the right permissions?
When I add those corrections, I get the menu item
Owen
thumbnail generation for nautilus via gimp
Hi Eckhard,
On Dec 6, 2007 6:29 AM, Eckhard M. Jäger wrote:
Hello,
i found the problem why the script doesn't showed up, it needs the file permission "Exexcute".
Do not know why, i have written exporters for Blender and plugins for gEdit both in Python but
they didn't need the permission "Exexcute".Ok, i'm new to Python Gimp plugins.
In fact, all Gimp plugins are executables; when you call a plugin, GIMP runs it and communicates with it through a pipe. GIMP does not implement any special behaviour for .py files. That is why Python plugins must be executable.
thumbnail generation for nautilus via gimp
Hi,
On Thu, 2007-12-06 at 10:59 +1030, David Gowers wrote:
In fact, all Gimp plugins are executables; when you call a plugin, GIMP runs it and communicates with it through a pipe. GIMP does not implement any special behaviour for .py files. That is why Python plugins must be executable.
In fact GIMP does implement special behavior for .py files. Or rather, pygimp tells GIMP that files ending in .py should be executed by the Python interpreter. This is what the third line in $(prefix)/lib/gimp/2.0/interpreters/pygimp.interp does. The effect is that you can omit the shebang (#!/usr/bin/python) if your plug-in's filename has the .py suffix.
But you are right that all plug-ins must be executable. Files that don't have the exectuable bit set are skipped when plug-ins are initialized.
Sven
thumbnail generation for nautilus via gimp
Hello,
i have written my Gimp python plugin so far:
#!/usr/bin/python
from gimpfu import *
import os
import os.path
def python_thumbnailer(this_path):
image_formats = [
".psd",
".xcf",
".rgb"
]
num_files = len (os.listdir(this_path))
all_files = os.listdir(this_path)
for this_file in range(num_files):
this_ext = ''
this_filepath = this_path+"/"+all_files[this_file]
if os.path.isfile(this_filepath):
this_ext = splitext(this_filepath)[1]
if this_ext in image_formats:
pdb.gimp_file_load(this_filepath,this_filepath)
pdb.gimp_file_save_thumbnail(this_filepath,this_filepath)
pdb.gimp_image_delete(this_filepath)
pdb.gimp_quit(0)
register(
"python-fu-thumbnailer",
"Generating thumbnails",
"Generating thumbnails for Nautilus via Gimp",
"Eckhard M. Jaeger",
"Eckhard M. Jaeger",
"2007",
"/Xtns/Nautilus Thumbnailer...",
"",
[
(PF_STRING, "this_path", "Directory Path", ""),
],
[],
python_thumbnailer)
main()
But when i try to execute it with gimp-console -i -n -f -d -s -b '(python_thumbnailer RUN-NONINTERACTIVE "/home/agy/psd_samples")'
i get always batch command: experienced an execution error.
Did somebody know what is wrong? Thanx.
-
|\/\/\/|
| |
| (O)(O) Bart.
C _) bart@neeneenee.de
| ,_/
| / - Ich bin nicht berechtigt Aushilfslehrer zu feuern -
/ \
http://www.neeneenee.de
thumbnail generation for nautilus via gimp
Hi,
On Fri, 2007-12-07 at 23:24 +0100, Eckhard M. Jäger wrote:
pdb.gimp_file_save_thumbnail(this_filepath,this_filepath) pdb.gimp_image_delete(this_filepath)
Both functions take an image object as the first parameter and not a filename.
Shouldn't you ask these kind of questions on the gimp-user mailing-list? This doesn't seem to be related to the development of GIMP.
Sven
thumbnail generation for nautilus via gimp
Hello David,
thanks for your help i get it fixed! http://my.opera.com/area42/blog/nautilus-thumbnailer-update
-
|\/\/\/|
| |
| (O)(O) Bart.
C _) bart@neeneenee.de
| ,_/
| / - Ich bin nicht berechtigt Aushilfslehrer zu feuern -
/ \
http://www.neeneenee.de
Am Freitag, den 14.12.2007, 08:17 +1030 schrieb David Gowers:
Hi Eckhard,
On Dec 14, 2007 5:36 AM, Eckhard M. Jäger wrote:
Hello David,
i followed your idea about doing the loop over the files inside Gimp (i attached the script).
I tested the script line by line using the builtin Python console of Gimp and it worked well so far.But when i try run this script from a shel using gimp-console -i -n -f -d -s -b '(python_thumbnailer "/home/agy/test")'
I always getting the message "batch command: experienced an execution error."
Do you have any idea what went wrong?
You can find out yourself just by looking at gimp's output in a terminal. The error is in this line:
this_ext = splitext(this_filepath)[1]
Thanx!
-
|\/\/\/|
| |
| (O)(O) Bart.
C _) bart@neeneenee.de
| ,_/
| / - Ich bin nicht berechtigt Aushilfslehrer zu feuern - / \
http://www.neeneenee.de