We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flattening GIF animations is heresy, I know. It was a difficult choice for our avatar system :)
I have a local PR where I tried implementing it in Go, but it blew up when trying to call C.WriteImages() in ToFile():
C.WriteImages()
ToFile()
Assertion failed: (images->signature == MagickSignature), function WriteImages, file magick/constitute.c, line 1340.
diff --git a/magick.go b/magick.go index 6a5a3b2..8bf45e3 100644 --- a/magick.go +++ b/magick.go @@ -458,6 +458,10 @@ func (im *MagickImage) Strip() (err error) { return } +func (im *MagickImage) Flatten() { + im.ReplaceImage(C.GetFirstImageInList(im.Image)) +} + // ToBlob takes a (transformed) MagickImage and returns a byte slice in the format you specify with extension. // Magick uses the extension to transform the image in to the proper encoding (e.g. "jpg", "png") func (im *MagickImage) ToBlob(extension string) (blob []byte, err error) { diff --git a/magick_test.go b/magick_test.go index ab11620..77ed59f 100644 --- a/magick_test.go +++ b/magick_test.go @@ -196,6 +196,19 @@ func TestNegateImage(t *testing.T) { assert.T(t, image != nil) } +func TestFlattenImage(t *testing.T) { + filename := "test/test_animated.gif" + image, error := NewFromFile(filename) + assert.T(t, error == nil) + assert.T(t, image != nil) + assert.T(t, image.Image != nil) + assert.T(t, image.ImageInfo != nil) + image.Flatten() + + err := image.ToFile("test/test_out2.gif") + assert.T(t, err == nil) +} + func TestToBlob(t *testing.T) { image := setupImage(t) bytes, err := image.ToBlob("png")
We solve this now by adding [0] to the input file name in the convert args.
[0]
convert
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Flattening GIF animations is heresy, I know. It was a difficult choice for our avatar system :)
I have a local PR where I tried implementing it in Go, but it blew up when trying to call
C.WriteImages()
inToFile()
:We solve this now by adding
[0]
to the input file name in theconvert
args.The text was updated successfully, but these errors were encountered: