Adding GIF, PDF and SVG support (libvips 8.3)

This commit is contained in:
Yoan Blanc 2016-08-23 11:40:01 +02:00
parent 308a36afc6
commit 6b76a33673
No known key found for this signature in database
GPG key ID: 6058CF4574298812
15 changed files with 843 additions and 11 deletions

17
vips.go
View file

@ -341,6 +341,12 @@ func vipsSave(image *C.VipsImage, o vipsSaveOptions) ([]byte, error) {
case PNG:
saveErr = C.vips_pngsave_bridge(tmpImage, &ptr, &length, 1, C.int(o.Compression), quality, interlace)
break
case GIF:
return nil, errors.New("VIPS cannot save to GIF")
case PDF:
return nil, errors.New("VIPS cannot save to PDF")
case SVG:
return nil, errors.New("VIPS cannot save to SVG")
default:
saveErr = C.vips_jpegsave_bridge(tmpImage, &ptr, &length, 1, quality, interlace)
break
@ -467,6 +473,17 @@ func vipsImageType(bytes []byte) ImageType {
(bytes[0] == 0x4D && bytes[1] == 0x4D && bytes[2] == 0x0 && bytes[3] == 0x2A) {
return TIFF
}
if bytes[0] == 'G' && bytes[1] == 'I' && bytes[2] == 'F' && bytes[3] == '8' &&
bytes[4] == '9' && bytes[5] == 'a' {
return GIF
}
if bytes[0] == '%' && bytes[1] == 'P' && bytes[2] == 'D' && bytes[3] == 'F' {
return PDF
}
if bytes[0] == '<' && bytes[1] == '?' && bytes[2] == 'x' && bytes[3] == 'm' &&
bytes[4] == 'l' && bytes[5] == ' ' {
return SVG
}
if HasMagickSupport && strings.HasSuffix(readImageType(bytes), "MagickBuffer") {
return MAGICK
}