简体   繁体   English

使用 python-fu 将 GIMP 图片导出为 png 未正确显示

[英]Exported GIMP picture to png using python-fu not displayed correctly

When I try to save an image using python-fu in GIMP, the picture is not displayed correctly in another software (pivview) I have to use.当我尝试在 GIMP 中使用 python-fu 保存图像时,图片在我必须使用的另一个软件(pivview)中无法正确显示。

When I export the picture manually, with all boxes above colormode unchecked, 16bpc RGB, comression level 5, IPTC-data unchecked and the other boxes below compression checked, the picture is displayed correctly.当我手动导出图片时,未选中颜色模式上方的所有框,16bpc RGB,压缩级别 5,未选中 IPTC 数据,并选中压缩下方的其他框,图片显示正确。
The picture in the software I have to use has all white columns every 4 pixels or so.我必须使用的软件中的图片每 4 个像素左右都有所有的白色列。 Using windows photos, the picture is displayed correctly.使用windows照片,图片显示正确。

The picture is 16bit uint grayscale.图片为 16bit uint 灰度。

In the python-fu console, I tried:在 python-fu 控制台中,我尝试了:

savedir = 'C:/Users/slowmoetion/Desktop'
fname = 'picture'
point1 = [1555,775]
point2 = [300,550]
img = gimp.image_list()[0]
layer_one = gimp.Layer(img,'dodge',img.width,img.height,GREY_IMAGE)
layer_one.mode = DODGE_MODE
img.add_layer(layer_one,0)
pdb.gimp_drawable_edit_gradient_fill(layer_one,0,0,True,5,3,True,point1[0],point1[1],point2[0],point2[1])
new_img = pdb.gimp_image_duplicate(img)
layer = pdb.gimp_image_merge_visible_layers(new_img, CLIP_TO_IMAGE)
new_img=pdb.gimp_image_convert_rgb(new_img) #didn't help
pdb.file_png_save2(new_img,new_img.layers[0],savedir+'/'+fname+'_1.png',fname+'_1.png',False,5,False,False,False,False,False,False,False)

I also tried switching the last False to True and some other switches, but I am out of ideas...我还尝试将最后一个False切换为True和其他一些开关,但我没有想法......
Using tiff did not help, pivview crashes when opening the exported files.使用 tiff 没有帮助,打开导出的文件时 pivview 崩溃。 Maybe someone here has an idea what I can try?也许这里有人知道我可以尝试什么?

Thanks a lot!非常感谢!

When the picture is 16bpc (or better with float formats), Gimp saves it by default as a 16bpc PNG which is a rather recent variant (or at least not as widely supported as the 8bpc one).当图片为 16bpc(或浮点格式更好)时,Gimp 默认将其保存为 16bpc PNG,这是一个相当新的变体(或至少不像 8bpc 那样被广泛支持)。 So my first experiment would be to export the image manually in Gimp and force the 16bpc and 8bpc format in the PNG save dialog, and see if the 16bpc format elicits the same behavior in your viewing app, while the 8bpc is displayed correctly.所以我的第一个实验是在 Gimp 中手动导出图像并在 PNG 保存对话框中强制使用 16bpc 和 8bpc 格式,并查看 16bpc 格式是否在您的查看应用程序中引发相同的行为,而 8bpc 显示正确。

If so you have to export an 8bpc PNG.如果是这样,您必须导出 8bpc PNG。 As far as I can tell there is no way to explicitly set the PNG bitness, but file_png_save() is sensitive to the image precision so you can export an 8bpc PNG by changing the image precision before export (on the image itself or a duplicate).据我所知,没有办法明确设置 PNG 位数,但file_png_save()对图像精度很敏感,因此您可以通过在导出前更改图像精度来导出 8bpc PNG(在图像本身或副本上) .

Come to think of it, it could also be a problem with the grayscale support, which could checked and fixed in a similar way.想一想,也可能是灰度支持的问题,可以用类似的方式检查和修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM