I know this can be done with matplotlib or PIL, but I need it to be done in blender, without installing any other package.
I searched and tried following code in blender, but only get a black image as output.
import bpy import numpy as np image_path = "src.jpg" output_image_path = "output.jpg" output_image_name = "output.jpg" image = bpy.data.images.load(image_path) np_array = np.asarray(image.pixels) # create output image output_image = bpy.data.images.new(output_image_name, width=image.size, height=image.size) output_image.file_format = 'JPEG' output_image.filepath = output_image_path # convert np array back to image output_image.pixels = np_array.ravel() output_image.save()
So, how to make this work? Thanks.