一次另存为多个文件(GIMP) [英] Save as on multiple files at once (GIMP)

查看:96
本文介绍了一次另存为多个文件(GIMP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一系列的 .xcf 图片,我想另存为 .png .我可以打开每个文件并将其另存为 .png ,但是由于有很多图像,因此需要花费大量时间.

是否有一种可以一次转换所有图像的方法,或者另一种方法是我可以花更少的时间来完成这项工作?

谢谢.

解决方案

我将为此使用GIMP中的Python控制台-如果您恰好在Windows中,请看看如何为GIMP 2.6安装Python扩展(在Linux上,它要么是孤立的,要么是安装gimp-python软件包的问题,​​在Mac OS上可能是相同的)

从GIMP的Python控制台中,您可以访问巨大的GIMP API,您可以通过查看help-> Procedure Browser对话框来进行检查-除了具有Python的所有其他功能之外,包括文件和Strign操作.

在Python-fu控制台中,您就是一个人,要做这样的事情:

import glob
for fname in glob.glob("*.xcf"):
    img = pdb.gimp_file_load(fname, fname)
    img.flatten()
    new_name = fname[:-4] + ".png"
    pdb.gimp_file_save(img, img.layers[0], new_name, new_name)

(这将在GIMP缺省使用的目录上起作用-将被desried的目录连接到文件路径上以在其他目录上使用).

如果您需要多次,请查看gimp-Python随附的示例插件,并将上面的代码粘贴为GIMP python插件的核心,以供您自己使用.

I have a series of .xcf images which I want to save as .png. I can open each file and save as .png but since there are a lot of images it would take a fair amount of time.

Is there a way to convert all images at once, or another way I have to spent less time on this job?

Thank you in advance.

解决方案

I'd use the Python console inside GIMP for that - if you happen to be in Windows, take a look on how to install the Python extension for GIMP 2.6 (on Linux it either comes isntalled or is a matter of installing the gimp-python package, probably the same on Mac OS)

From within GIMP's Python console you have access to a huge GIMP API you can check by looking at the help->Procedure Browser dialog - besides having all the other features of Python, including file and strign manipulation.

One you are =in the Python-fu console, it is matter of doing something like this:

import glob
for fname in glob.glob("*.xcf"):
    img = pdb.gimp_file_load(fname, fname)
    img.flatten()
    new_name = fname[:-4] + ".png"
    pdb.gimp_file_save(img, img.layers[0], new_name, new_name)

(this will work on the directory GIMP uses as default - concatenate the desried directory to the filepaths to work on other dirs).

If you need to that more than once, take a look on the example plugins that come with gimp-Python, and paste the code above as the core fo a python plug-in for GIMP for your own use.

这篇关于一次另存为多个文件(GIMP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆