Wand Creates Empty Frame And Irregular Frame Rate
I have below snippet which creates a gif. This snippet is derived from hints here. The snippet creates an empty frame and frames have irregular delay between them. Notice delay bet
Solution 1:
As per hints given in solution here, I came up with below modified snippet which seems to solve the issue. Apparantly my requirement requires MagickSetImageDispose
or MagickExtentImage
which are not yet implemented in wand. I am very thank ful to emcconville for this help and request him to add his comments if any needed for below solution. I am still exploring. In case of any further issue on this problem, I will get back.
def render(self):
wand = Image2()
#get max frame height, width
frameSizeList = []
tempImgList = []
for each_frame in self._tree_dot_frames:
img = Image2(blob=each_frame)
frameSizeList.append((img.width,img.height))
tempImgList.append(img)
optimalFrameSize = (max(frameSizeList,key=itemgetter(1)))
#print('Max Frame size detected: ',optimalFrameSize)
#create frames
for each_frame in tempImgList:
newImg = Image2(width=optimalFrameSize[0], height=optimalFrameSize[1], background=Color('WHITE'))
newImg.composite(each_frame,0,0)
wand.sequence.append(newImg)
#set frame rate
for cursor in range(len(self._tree_dot_frames)):
with wand.sequence[cursor] as frame:
print('sequence width: {} height: {}'.format(frame.width,frame.height))
frame.delay = 100
#wand.merge_layers('merge')
wand.format = 'gif'
wand.save(filename='animated.gif')
print('No of frames: {} gif width: {} height: {}'.format(len(wand.sequence),wand.width,wand.height))
self._tree_dot_blob = wand.make_blob()
return self._tree_dot_blob
Post a Comment for "Wand Creates Empty Frame And Irregular Frame Rate"