How can I declare in python the pixel size (height and width) in which I want to save a figure (not just dpi, the exact number of pixels)? I've seen a lot of similar questions, but quite old and none of them seems to work (example1 example2).
I would also like to know if by doing so it's possible to change the aspect ratio of an image? I have a 11227x11229 pixels image, I would like to open it in python and save it as a 11230x11229, but so far can't achieve it.
Right now this is how I save my image, but I have to play with the "dpi" setting to approach the desired resolution. It's tedious, I can't always have the exact resolution and I can't change the aspect ratio like intended:
fig, ax = plt.subplots()
plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, hspace = 0, wspace = 0)
plt.axis('off')
plt.imshow(superpositionFINAL)
plt.savefig('myImage.png', bbox_inches='tight', pad_inches = 0, dpi=2807.8)
plt.show()
Thanks