Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gimp 选择复制粘贴_Gimp_Python Fu - Fatal编程技术网

Gimp 选择复制粘贴

Gimp 选择复制粘贴,gimp,python-fu,Gimp,Python Fu,第二天,我是python fu的新手,所以我的问题可能看起来很幼稚:我想从r400r.png中选择一个矩形部分,将其旋转90度,然后将我的选择保存在r400ra.png中 到目前为止,我在这些方面做了一些尝试: for fv in range(400,401): fn='r%sr.png' % fv img=pdb.gimp_file_load('/path/'+fn,fn) drw=pdb.gimp_image_get_active_layer(img) img1=pdb.gi

第二天,我是python fu的新手,所以我的问题可能看起来很幼稚:我想从r400r.png中选择一个矩形部分,将其旋转90度,然后将我的选择保存在r400ra.png中

到目前为止,我在这些方面做了一些尝试:

for fv in range(400,401):
  fn='r%sr.png' % fv
  img=pdb.gimp_file_load('/path/'+fn,fn)
  drw=pdb.gimp_image_get_active_layer(img)
  img1=pdb.gimp_image_new(1024,1568,0)
  lyr=pdb.gimp_layer_new(img1,1024,1568,0,'ly1',0,0)

  pdb.gimp_rect_select(img,10,200,1422,1024,2,0,0)
  drw=pdb.gimp_rotate(drw,0,1.570796327)
  pdb.script_fu_selection_to_image(img1,drw)
  f0=fn[:5]+'a'+fn[5:]
  pdb.gimp_file_save(drw,'/path/'+f0,f0)
lyr层在那里是因为我的理解是它是必须的,尽管我不清楚为什么。for循环最终应该批量处理一堆文件;对于测试,它仅限于一个文件。我在尝试执行脚本\u fu\u选择\u到\u图像时出错

请你给我指一下正确的方向好吗

谢谢,
SxN

PDB调用按以下顺序执行会更好:

# import your image:
img=pdb.gimp_file_load('/path/'+fn,fn)

#make the selection
pdb.gimp_rect_select(img,10,200,1422,1024,2,0,0)


# copy
pdb.gimp_edit_copy(img.layers[0])
# (no need to "get_active_layer" - if
# your image is a flat PNG or JPG, it only has one layer,
# which is accessible as img.layers[0]) 

# create a new image from the copied area:
new_img = pdb.gimp_paste_as_new()

#rotate the newly created image:
pdb.gimp_image_rotate(new_img, ...)

#export the resulting image:
pdb.gimp_file_save(new_img, ...)

#delete the loaded image and the created image:
# (as the objects being destroyed on the Python side
# do not erase then from the GIMP app, where they
# stay consuming memory)
pdb.gimp_image_delete(new_img)
pdb.gimp_image_delete(img)

PDB调用按以下顺序执行会更好:

# import your image:
img=pdb.gimp_file_load('/path/'+fn,fn)

#make the selection
pdb.gimp_rect_select(img,10,200,1422,1024,2,0,0)


# copy
pdb.gimp_edit_copy(img.layers[0])
# (no need to "get_active_layer" - if
# your image is a flat PNG or JPG, it only has one layer,
# which is accessible as img.layers[0]) 

# create a new image from the copied area:
new_img = pdb.gimp_paste_as_new()

#rotate the newly created image:
pdb.gimp_image_rotate(new_img, ...)

#export the resulting image:
pdb.gimp_file_save(new_img, ...)

#delete the loaded image and the created image:
# (as the objects being destroyed on the Python side
# do not erase then from the GIMP app, where they
# stay consuming memory)
pdb.gimp_image_delete(new_img)
pdb.gimp_image_delete(img)

这个问题已经两年了,但是。。。在Ubuntu中使用gimp v2.8.10,pdb.gimp_paste_as_new行触发错误:在gimp v2.8.10中找不到过程,该函数现在称为pdb.gimp_edit_paste_as_new这个问题已经两年了,但是。。。在Ubuntu中使用gimp v2.8.10,行pdb.gimp_paste_as_new会触发错误:在gimp v2.8.10中找不到过程,此函数现在称为pdb.gimp_edit_paste_as_new