It looks like you're new here. If you want to get involved, click one of these buttons!
I found that supposedly there is a bug with renamed *.tif images. It seems like it may be related to the incorrect heading in the file. I found workaround for me using PIL package but I hope you may be interested in this. Code sample below.
import pya import os from PIL import Image directory = os.path.dirname(os.path.realpath(__file__)) path_tif = os.path.join(directory, "test.tif") path_png = os.path.join(directory, "test.png") img = pya.Image(path_tif) image2 = Image.open(path_tif) image2.save(path_png) img2 = pya.Image(path_png) flag = False for i in range(img.width()): for j in range(img.height()): if img.get_pixel(i, j) != 0: print("Hooray! img") flag = True break if flag: break flag = False for i in range(img2.width()): for j in range(img2.height()): if img2.get_pixel(i, j) != 0: print("Hooray! img2") flag = True break if flag: break os.remove(path_png) pya.Application.instance().main_window().current_view().insert_image(img)
File example should be placed in folder containg script sample.
What is interesting, that when image is inserted it is anyway has right colours.