我使用的是python库Image,无法将图片保存在更高的DPI中。
以下是代码:
import Image as im
import ImageFilter as imf
frame = im.new('RGBA', (300,300), "white")
c = frame.load()
for m in range(0,pylab.size(mutInts)):
#Convert the mutation into a colour
r = make_r(mutInts[m])
g = make_g(mutInts[m])
b = make_b(mutInts[m])
if (type(r) != int):
r = 150
print "error: returned r was not an int.. subbing in 150"
if (type(g) != int):
g = 150
print "error: returned g was not an int.. subbing in 150"
if (type(b) != int):
b = 150
print "error: returned b was not an int.. subbing in 150"
c[int(i[m]),300-int(j[m])] = (r, g, b, 255)
print frame.size
frame = frame.resize([int(3*s) for s in frame.size])
frame = frame.filter(imf.SMOOTH_MORE)
picturefilename = newLocation + 'picture_' + filename[:-4] + '.jpg'
#Save the picture
frame.save(picturefilename)
我认为frame.save可能有一个我可以使用的dpi选项,但我还没找到任何东西。任何帮助控制尺寸和DPI赞赏!