简体   繁体   中英

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.

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.
The picture in the software I have to use has all white columns every 4 pixels or so. Using windows photos, the picture is displayed correctly.

The picture is 16bit uint grayscale.

In the python-fu console, I tried:

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...
Using tiff did not help, pivview crashes when opening the exported files. 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). 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.

If so you have to export an 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).

Come to think of it, it could also be a problem with the grayscale support, which could checked and fixed in a similar way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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