clementfarabet / graphicsmagick

A simple Lua wrapper to graphicsmagick.
127 stars 41 forks source link

Setting the image index before any transforming process. #4

Open lvkerang opened 11 years ago

lvkerang commented 11 years ago

At the end of method MagickReadImage, MagickReadImageBlob and MagickReadImageFile, the wand->image was pointed to the last frame in the image list. For multi-frame image, the image index should be set to 0 (first frame) before any transforming process.

Invoke MagickSetImageIndex after reading image, e.g.

clib.MagickReadImageBlob(self.wand, ffi.cast('const void *', blob), size)
clib.MagickSetImageIndex(self.wand, 0)

or add new method:

-- Setting the image index:
function Image:setImageIndex(i)
    clib.MagickSetImageIndex(self.wand, i or 0)
end
...
image:setImageIndex(0)
image:size(120, 120)