Browse Source

Fix lint issues

DarthSim 6 years ago
parent
commit
69594894a0
3 changed files with 7 additions and 9 deletions
  1. 3 3
      heic.go
  2. 3 3
      image_type.go
  3. 1 3
      process.go

+ 3 - 3
heic.go

@@ -52,13 +52,13 @@ func heifReadFtyp(r io.Reader, boxDataSize int64) error {
 		return err
 	}
 
-	if bytes.Compare(data[0:4], heicBrand) == 0 {
+	if bytes.Equal(data[0:4], heicBrand) {
 		return nil
 	}
 
 	if boxDataSize >= 12 {
 		for i := int64(8); i < boxDataSize; i += 4 {
-			if bytes.Compare(data[i:i+4], heicBrand) == 0 {
+			if bytes.Equal(data[i:i+4], heicBrand) {
 				return nil
 			}
 		}
@@ -95,7 +95,7 @@ func heifReadHldr(r io.Reader, boxDataSize int64) error {
 		return err
 	}
 
-	if bytes.Compare(data[8:12], heicPict) != 0 {
+	if !bytes.Equal(data[8:12], heicPict) {
 		return fmt.Errorf("Invalid handler. Expected: pict, actual: %s", data[8:12])
 	}
 

+ 3 - 3
image_type.go

@@ -7,9 +7,9 @@ package main
 import "C"
 
 import (
-	"path/filepath"
 	"fmt"
 	"net/url"
+	"path/filepath"
 	"strings"
 )
 
@@ -71,9 +71,9 @@ func (it imageType) String() string {
 func (it imageType) Mime() string {
 	if mime, ok := mimes[it]; ok {
 		return mime
-	} else {
-		return "application/octet-stream"
 	}
+
+	return "application/octet-stream"
 }
 
 func (it imageType) ContentDisposition(imageURL string) string {

+ 1 - 3
process.go

@@ -481,14 +481,13 @@ func transformImage(ctx context.Context, img **C.VipsImage, data []byte, po *pro
 
 func transformAnimated(ctx context.Context, img **C.VipsImage, data []byte, po *processingOptions, imgtype imageType) error {
 	imgWidth := int((*img).Xsize)
-	imgHeight := int((*img).Ysize)
 
 	frameHeight, err := vipsGetInt(*img, "page-height")
 	if err != nil {
 		return err
 	}
 
-	framesCount := minInt(imgHeight/frameHeight, conf.MaxGifFrames)
+	framesCount := minInt(int((*img).Ysize)/frameHeight, conf.MaxGifFrames)
 
 	// Double check dimensions because animated image has many frames
 	if err := checkDimensions(imgWidth, frameHeight*framesCount); err != nil {
@@ -509,7 +508,6 @@ func transformAnimated(ctx context.Context, img **C.VipsImage, data []byte, po *
 		}
 
 		imgWidth = int((*img).Xsize)
-		imgHeight = int((*img).Ysize)
 
 		frameHeight, err = vipsGetInt(*img, "page-height")
 		if err != nil {