• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang imaging.Resize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/disintegration/imaging.Resize函数的典型用法代码示例。如果您正苦于以下问题:Golang Resize函数的具体用法?Golang Resize怎么用?Golang Resize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Resize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: GetCube

// Sets skin.Processed to an isometric render of the head from a top-left angle (showing 3 sides).
func (skin *mcSkin) GetCube(width int) error {
	// Crop out the top of the head
	topFlat := imaging.Crop(skin.Image, image.Rect(8, 0, 16, 8))
	// Resize appropriately, so that it fills the `width` when rotated 45 def.
	topFlat = imaging.Resize(topFlat, int(float64(width)*math.Sqrt(2)/3+1), 0, imaging.NearestNeighbor)
	// Create the Gift filter
	filter := gift.New(
		gift.Rotate(45, color.Transparent, gift.LinearInterpolation),
	)
	bounds := filter.Bounds(topFlat.Bounds())
	top := image.NewNRGBA(bounds)
	// Draw it on the filter, then smush it!
	filter.Draw(top, topFlat)
	top = imaging.Resize(top, width+2, width/3, imaging.NearestNeighbor)
	// Skew the front and sides at 15 degree angles to match up with the
	// head that has been smushed
	front := skin.cropHead(skin.Image).(*image.NRGBA)
	side := imaging.Crop(skin.Image, image.Rect(0, 8, 8, 16))
	front = imaging.Resize(front, width/2, int(float64(width)/1.75), imaging.NearestNeighbor)
	side = imaging.Resize(side, width/2, int(float64(width)/1.75), imaging.NearestNeighbor)
	front = skewVertical(front, math.Pi/12)
	side = skewVertical(imaging.FlipH(side), math.Pi/-12)

	// Create a new image to assemble upon
	skin.Processed = image.NewNRGBA(image.Rect(0, 0, width, width))
	// Draw each side
	draw.Draw(skin.Processed.(draw.Image), image.Rect(0, width/6, width/2, width), side, image.Pt(0, 0), draw.Src)
	draw.Draw(skin.Processed.(draw.Image), image.Rect(width/2, width/6, width, width), front, image.Pt(0, 0), draw.Src)
	// Draw the top we created
	draw.Draw(skin.Processed.(draw.Image), image.Rect(-1, 0, width+1, width/3), top, image.Pt(0, 0), draw.Over)

	return nil
}
开发者ID:spideynn,项目名称:imgd,代码行数:34,代码来源:process.go


示例2: transformImage

// transformImage modifies the image m based on the transformations specified
// in opt.
func transformImage(m image.Image, opt Options) image.Image {
	// resize if needed
	if w, h, resize := resizeParams(m, opt); resize {
		if opt.Fit {
			m = imaging.Fit(m, w, h, resampleFilter)
		} else {
			if w == 0 || h == 0 {
				m = imaging.Resize(m, w, h, resampleFilter)
			} else {
				m = imaging.Resize(m, w, h, imaging.Lanczos)
			}
		}
	}

	// flip
	if opt.FlipVertical {
		m = imaging.FlipV(m)
	}
	if opt.FlipHorizontal {
		m = imaging.FlipH(m)
	}

	// rotate
	switch opt.Rotate {
	case 90:
		m = imaging.Rotate90(m)
	case 180:
		m = imaging.Rotate180(m)
	case 270:
		m = imaging.Rotate270(m)
	}

	return m
}
开发者ID:timchunght,项目名称:imageproxy,代码行数:36,代码来源:transform.go


示例3: generateThumbnailImage

func generateThumbnailImage(img image.Image, thumbnailPath string, width int, height int) {
	thumbWidth := float64(utils.Cfg.FileSettings.ThumbnailWidth)
	thumbHeight := float64(utils.Cfg.FileSettings.ThumbnailHeight)
	imgWidth := float64(width)
	imgHeight := float64(height)

	var thumbnail image.Image
	if imgHeight < thumbHeight && imgWidth < thumbWidth {
		thumbnail = img
	} else if imgHeight/imgWidth < thumbHeight/thumbWidth {
		thumbnail = imaging.Resize(img, 0, utils.Cfg.FileSettings.ThumbnailHeight, imaging.Lanczos)
	} else {
		thumbnail = imaging.Resize(img, utils.Cfg.FileSettings.ThumbnailWidth, 0, imaging.Lanczos)
	}

	buf := new(bytes.Buffer)
	if err := jpeg.Encode(buf, thumbnail, &jpeg.Options{Quality: 90}); err != nil {
		l4g.Error(utils.T("api.file.handle_images_forget.encode_jpeg.error"), thumbnailPath, err)
		return
	}

	if err := WriteFile(buf.Bytes(), thumbnailPath); err != nil {
		l4g.Error(utils.T("api.file.handle_images_forget.upload_thumb.error"), thumbnailPath, err)
		return
	}
}
开发者ID:Rudloff,项目名称:platform,代码行数:26,代码来源:file.go


示例4: ExtractThumbnail

// Extracts thumbnail
func (c *Convertor) ExtractThumbnail(file string, info os.FileInfo) {
	c.CurrFile += 1

	cover, err := c.GetCoverImage(file, info)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error GetCoverImage: %v\n", err.Error())
		return
	}

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error Thumbnail: %v\n", err.Error())
		return
	}

	if c.Opts.Width > 0 || c.Opts.Height > 0 {
		if c.Opts.Fit {
			cover = imaging.Fit(cover, c.Opts.Width, c.Opts.Height, filters[c.Opts.Filter])
		} else {
			cover = imaging.Resize(cover, c.Opts.Width, c.Opts.Height, filters[c.Opts.Filter])
		}
	} else {
		cover = imaging.Resize(cover, 256, 0, filters[c.Opts.Filter])
	}

	imagick.Initialize()

	mw := imagick.NewMagickWand()
	defer mw.Destroy()

	b := new(bytes.Buffer)
	png.Encode(b, cover)

	err = mw.ReadImageBlob(b.Bytes())
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error ReadImageBlob: %v\n", err.Error())
	}

	var fileuri string
	var filename string

	if c.Opts.Outfile == "" {
		fileuri = "file://" + file
		filename = filepath.Join(c.Opts.Outdir, fmt.Sprintf("%x.png", md5.Sum([]byte(fileuri))))
	} else {
		abs, _ := filepath.Abs(c.Opts.Outfile)
		fileuri = "file://" + abs
		filename = abs
	}

	mw.SetImageFormat("PNG")
	mw.SetImageProperty("Software", "CBconvert")
	mw.SetImageProperty("Description", "Thumbnail of "+fileuri)
	mw.SetImageProperty("Thumb::URI", fileuri)
	mw.SetImageProperty("Thumb::MTime", strconv.FormatInt(info.ModTime().Unix(), 10))
	mw.SetImageProperty("Thumb::Size", strconv.FormatInt(info.Size(), 10))
	mw.SetImageProperty("Thumb::Mimetype", mime.TypeByExtension(filepath.Ext(file)))

	mw.WriteImage(filename)
}
开发者ID:gen2brain,项目名称:cbconvert,代码行数:60,代码来源:cbconvert.go


示例5: ExtractCover

// Extracts cover
func (c *Convertor) ExtractCover(file string, info os.FileInfo) {
	c.CurrFile += 1

	cover, err := c.GetCoverImage(file, info)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error GetCoverImage: %v\n", err.Error())
		return
	}

	if c.Opts.Width > 0 || c.Opts.Height > 0 {
		if c.Opts.Fit {
			cover = imaging.Fit(cover, c.Opts.Width, c.Opts.Height, filters[c.Opts.Filter])
		} else {
			cover = imaging.Resize(cover, c.Opts.Width, c.Opts.Height, filters[c.Opts.Filter])
		}
	}

	filename := filepath.Join(c.Opts.Outdir, fmt.Sprintf("%s.jpg", c.getBasename(file)))
	f, err := os.Create(filename)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error Create: %v\n", err.Error())
		return
	}
	defer f.Close()

	jpeg.Encode(f, cover, &jpeg.Options{c.Opts.Quality})
}
开发者ID:gen2brain,项目名称:cbconvert,代码行数:28,代码来源:cbconvert.go


示例6: ResizeHandler

func ResizeHandler(w http.ResponseWriter, r *http.Request) {
	// parse url vars
	v := mux.Vars(r)
	width, _ := v["width"]
	height, _ := v["height"]
	x, _ := strconv.Atoi(width)
	y, _ := strconv.Atoi(height)

	imageUrl, _ := v["imageUrl"]
	m := getImg(imageUrl)

	cropBox, _ := getFillCrop(m, float32(x)/float32(y))
	cropRect := image.Rect(cropBox.X, cropBox.Y, cropBox.X+cropBox.Width, cropBox.Y+cropBox.Height)
	croppedImg := imaging.Crop(m, cropRect)

	// convert to opencv image
	//srcImage := opencv.FromImage(m)
	//if srcImage == nil {
	//  fmt.Printf("Couldn't create opencv Image")
	//}
	//defer srcImage.Release()
	//croppedImage := opencv.Crop(srcImage, cropBox.X, cropBox.Y, cropBox.Width, cropBox.Height)
	//resizedImage := opencv.Resize(croppedImage, x, y, opencv.CV_INTER_LINEAR)
	resizedImage := imaging.Resize(croppedImg, x, y, imaging.CatmullRom)
	jpeg.Encode(w, resizedImage, &jpeg.Options{Quality: 90})
}
开发者ID:zmilan,项目名称:go-resize,代码行数:26,代码来源:server.go


示例7: decodeFunc

func decodeFunc(h []string) func(rec []string) (draw.Image, error) {
	if h[0] == "ImageId" {
		return decodePGM
	}
	if h[0] == "left_eye_center_x" {
		return func(rec []string) (draw.Image, error) {
			src, err := decodePGM(rec)
			if err != nil {
				return nil, err
			}
			b := src.Bounds()
			img := image.NewRGBA(b)
			draw.Draw(img, b, src, b.Min, draw.Src)
			for i := 0; i < len(rec)/2; i++ {
				/*                x, err := strconv.ParseFloat(rec[2*i], 64)
				                  if err != nil {
				                      log.Print(err)
				                      continue
				                  }
				                  y, err := strconv.ParseFloat(rec[2*i + 1], 64)
				                  if err != nil {
				                      log.Print(err)
				                      continue
				                  }
				                  img.Set(int(x + 0.5), int(y + 0.5), color.RGBA{0xff, 0, 0, 0xff})*/
			}
			// overlayPoints(
			i := imaging.Resize(img, 500, 0, imaging.Lanczos)
			return i, nil
		}
	}
	return nil
}
开发者ID:postfix,项目名称:kaggle--facial-keypoints,代码行数:33,代码来源:load.go


示例8: Resized

func Resized(ext string, data []byte, width, height int) (resized []byte, w int, h int) {
	if width == 0 && height == 0 {
		return data, 0, 0
	}
	srcImage, _, err := image.Decode(bytes.NewReader(data))
	if err == nil {
		bounds := srcImage.Bounds()
		var dstImage *image.NRGBA
		if bounds.Dx() > width && width != 0 || bounds.Dy() > height && height != 0 {
			if width == height && bounds.Dx() != bounds.Dy() {
				dstImage = imaging.Thumbnail(srcImage, width, height, imaging.Lanczos)
				w, h = width, height
			} else {
				dstImage = imaging.Resize(srcImage, width, height, imaging.Lanczos)
			}
		} else {
			return data, bounds.Dx(), bounds.Dy()
		}
		var buf bytes.Buffer
		switch ext {
		case ".png":
			png.Encode(&buf, dstImage)
		case ".jpg", ".jpeg":
			jpeg.Encode(&buf, dstImage, nil)
		case ".gif":
			gif.Encode(&buf, dstImage, nil)
		}
		return buf.Bytes(), dstImage.Bounds().Dx(), dstImage.Bounds().Dy()
	} else {
		glog.Error(err)
	}
	return data, 0, 0
}
开发者ID:netroby,项目名称:seaweedfs,代码行数:33,代码来源:resizing.go


示例9: Resize

func (api *Api) Resize(imgloc string, xsize, ysize int, resizeType string) bool {
	dest := setSize(imgloc, xsize, ysize)
	if _, err := os.Stat(dest); err == nil {
		return true
	}
	bts, err := ioutil.ReadFile(imgloc)
	if err != nil {
		fmt.Println(err)
		return false
	}
	rdr := bytes.NewReader(bts)
	i, _, err := image.Decode(rdr)
	if err != nil {
		fmt.Println(err)
		return false
	}
	var fsimg *image.NRGBA
	switch resizeType {
	case "fit":
		fsimg = imaging.Fit(i, xsize, ysize, imaging.Lanczos)
	case "thumb":
		fsimg = imaging.Thumbnail(i, xsize, ysize, imaging.Lanczos)
	default:
		fsimg = imaging.Resize(i, xsize, ysize, imaging.Lanczos)
	}
	out, err := os.Create(dest)
	if err != nil {
		return false
	}
	defer out.Close()
	jpeg.Encode(out, fsimg, nil)
	return true
}
开发者ID:sisteamnik,项目名称:guseful,代码行数:33,代码来源:api.go


示例10: CenterCrop

func CenterCrop(img *io.Reader, width, height int) ([]byte, error) {
	m, _, err := image.Decode(*img)
	if err != nil {
		return nil, err
	}

	// TODO: I probably can switch to using imaging.Thumbnail here.
	imgW := float64(m.Bounds().Max.X - m.Bounds().Min.X)
	imgH := float64(m.Bounds().Max.Y - m.Bounds().Min.Y)
	targetW := float64(width)
	targetH := float64(height)

	var scale float64

	if imgW*targetH > targetW*imgH {
		scale = targetH / imgH
	} else {
		scale = targetW / imgW
	}

	m = imaging.Resize(m, int(imgW*scale), int(imgH*scale), imaging.Lanczos)
	m = imaging.CropCenter(m, width, height)

	buf := new(bytes.Buffer)
	jpeg.Encode(buf, m, &jpeg.Options{Quality: 95})

	return buf.Bytes(), nil
}
开发者ID:EverythingMe,项目名称:supersizeme,代码行数:28,代码来源:transform.go


示例11: resizePreview

func (image *Image) resizePreview(errorChan chan error, srcImage image.Image) {
	size := srcImage.Bounds().Size()
	ratio := float64(size.Y) / float64(size.X)
	targetHeight := int(float64(widthPreview) * ratio)

	dstImage := imaging.Resize(srcImage, widthPreview, targetHeight, imaging.Lanczos)
	dest := "./data/images/preview/" + image.Location
	errorChan <- imaging.Save(dstImage, dest)
}
开发者ID:Catorpilor,项目名称:Gophr,代码行数:9,代码来源:image.go


示例12: resizeImage

func resizeImage(filename string, size int) string {
	resizedFile := filename + ".resized.png"
	img, err := imaging.Open(filename)
	if err != nil {
		panic(err)
	}
	dstimg := imaging.Resize(img, size, 0, imaging.Box)
	imaging.Save(dstimg, resizedFile)
	return resizedFile
}
开发者ID:Daio-io,项目名称:pic-sizer,代码行数:10,代码来源:main.go


示例13: resizeOrCrop

/* resize when there is no height constraint, otherwise crop */
func (result *imageInfo) resizeOrCrop(img image.Image, width int, height int) image.Image {
	var imgdata image.Image
	if height == 0 {
		imgdata = imaging.Resize(img, width, height, imaging.Lanczos)
	} else {
		imgdata = imaging.CropCenter(img, width, height)
	}
	result.width = imgdata.Bounds().Max.X
	result.height = imgdata.Bounds().Max.Y
	return imgdata
}
开发者ID:didrocks,项目名称:site-julie,代码行数:12,代码来源:processing.go


示例14: GenerateThumbnail

func (be *Backend) GenerateThumbnail(bin string, filename string, width int, height int, crop bool) error {
	f, err := be.GetFileMetaData(bin, filename)
	if err != nil {
		return err
	}

	if strings.Split(f.MIME, "/")[0] != "image" {
		return errors.New("Batch job skipped: " + filename + " is not an image")
	}

	fpath := filepath.Join(be.filedir, bin, filename)
	cachedir := filepath.Join(be.filedir, bin, ".cache")
	if !isDir(cachedir) {
		if err := os.Mkdir(cachedir, 0700); err != nil {
			return err
		}
	}
	dst := filepath.Join(cachedir, strconv.Itoa(width)+"x"+strconv.Itoa(height)+"-"+filename)

	// Optimize to skip thumbnail generation if the thumbnail file exists
	// and is newer than the file.
	fi, err := os.Lstat(dst)
	if err == nil {
		if f.CreatedAt.After(fi.ModTime()) {
			// File newer than thumbnail. Ok to generate.
		} else {
			// File older than thumbnail. No need to generate.
			return nil
		}
	}

	s, err := imaging.Open(fpath)
	if err != nil {
		return err
	}

	if crop {
		im := imaging.Fill(s, width, height, imaging.Center, imaging.Lanczos)
		err = imaging.Save(im, dst)
	} else {
		im := imaging.Resize(s, width, height, imaging.Lanczos)
		err = imaging.Save(im, dst)
	}

	f.Links = be.GenerateLinks(f.Bin, f.Filename)
	be.Lock()
	defer be.Unlock()
	id := bin + filename
	delete(be.files, id)
	be.files[id] = f

	return err
}
开发者ID:espebra,项目名称:filebin,代码行数:53,代码来源:fs.go


示例15: normalizeInput

func normalizeInput(input image.Image, maxSize int) (image.Image, float64, error) {
	var scale float64
	if input.Bounds().Dx() > maxSize {
		scale = float64(input.Bounds().Dx()) / float64(maxSize)
	} else {
		scale = float64(input.Bounds().Dy()) / float64(maxSize)
	}

	log.Printf("Normalizing to %dx%d\n", int(float64(input.Bounds().Dx())/scale), int(float64(input.Bounds().Dy())/scale))
	resized := imaging.Resize(input, int(float64(input.Bounds().Dx())/scale), int(float64(input.Bounds().Dy())/scale), imaging.Lanczos)

	return resized, scale, nil
}
开发者ID:marvin0815,项目名称:gridfs-image-server,代码行数:13,代码来源:smartcrop.go


示例16: MakeFromImage

func MakeFromImage(srcImage image.Image, t string, w, h int) (image *image.NRGBA, err error) {
	switch t {
	case "thumbnail":
		image = imaging.Thumbnail(srcImage, w, h, imaging.Lanczos)
	case "resize":
		image = imaging.Resize(srcImage, w, h, imaging.Lanczos)
	case "fit":
		image = imaging.Fit(srcImage, w, h, imaging.Lanczos)
	default:
		image = imaging.Thumbnail(srcImage, w, h, imaging.Lanczos)
	}

	return image, nil
}
开发者ID:netw0rm,项目名称:reweb,代码行数:14,代码来源:utils.go


示例17: thumbs

func thumbs(args []string, thumbSizes []int) {
	if newThumbsSizes != "" {
		vals := strings.Split(newThumbsSizes, ",")
		thumbSizes = make([]int, len(vals))
		for i := 0; i < len(vals); i++ {
			numstr := strings.TrimSpace(vals[i])
			if numstr == "" {
				thumbSizes[i] = 0
				continue
			}
			num, err := strconv.Atoi(numstr)
			if err != nil {
				log.Print(err)
				continue
			}
			thumbSizes[i] = num
		}
	}

	for i := 0; i < len(args); i++ {

		file := args[i]
		ext := filepath.Ext(file)

		_, err := os.Stat(file)
		if err != nil {
			log.Fatal("file " + file + " is not accessible")
		}

		img, err := imaging.Open(file)
		if err != nil {
			log.Fatal(err)
		}

		for j := 0; j < len(thumbSizes); j++ {
			if thumbSizes[j] == 0 {
				continue
			}
			resized := imaging.Resize(img, thumbSizes[j], 0, imaging.Lanczos)
			rect := resized.Bounds().Max
			out := fmt.Sprintf("%s_%dx%d%s",
				strings.TrimSuffix(file, ext), rect.X, rect.Y, ext)
			err = imaging.Save(resized, out)
			log.Println("saved " + out)
			if err != nil {
				log.Fatal(err)
			}
		}
	}
}
开发者ID:chairraver,项目名称:img4hugo,代码行数:50,代码来源:img4hugo.go


示例18: Resize

func Resize(src io.Reader, c *CacheContext) (io.Reader, error) {
	raw, err := ioutil.ReadAll(src)
	if err != nil {
		return nil, err
	}

	width := c.Width
	data := bytes.NewReader(raw)
	img, format, err := image.Decode(data)
	if err != nil {
		return nil, err
	}
	var resizedImage image.NRGBA
	if c.Crop {

		minDimension := int(math.Min(float64(img.Bounds().Size().X), float64(img.Bounds().Size().Y)))

		if minDimension < c.Width || c.Width == 0 {
			width = minDimension
		}

		resizedImage = *imaging.Fill(img, width, width, imaging.Center, imaging.Lanczos)
	} else {
		resizedImage = *imaging.Resize(img, width, 0, imaging.Lanczos)
	}

	buf := new(bytes.Buffer)
	var imgFormat imaging.Format
	switch format {
	case "png":
		imgFormat = imaging.PNG
	case "jpeg":
		imgFormat = imaging.JPEG
	case "tiff":
		imgFormat = imaging.TIFF
	case "bmp":
		imgFormat = imaging.BMP
	default:
		return nil, errors.New("unsupported image format")
	}

	err = imaging.Encode(buf, resizedImage.SubImage(resizedImage.Rect), imgFormat)
	if err != nil {
		return nil, err
	}

	return buf, err

}
开发者ID:WorkHorseIndustries,项目名称:vip,代码行数:49,代码来源:manip.go


示例19: fitCropScale

func fitCropScale(i image.Image, r image.Rectangle) image.Image {
	wantRatio := float64(r.Bounds().Dx()) / float64(r.Bounds().Dy())
	haveRatio := float64(i.Bounds().Dx()) / float64(i.Bounds().Dy())

	sliceRect := image.Rectangle{}

	if haveRatio > wantRatio {
		wantwidth := wantRatio * float64(i.Bounds().Dy())
		sliceRect = image.Rect(i.Bounds().Dx()/2-int(wantwidth/2), 0, i.Bounds().Dx()/2+int(wantwidth/2), i.Bounds().Dy())
	} else {
		wantheight := float64(i.Bounds().Dx()) / wantRatio
		sliceRect = image.Rect(0, i.Bounds().Dy()/2-int(wantheight/2), i.Bounds().Dx(), i.Bounds().Dy()/2+int(wantheight/2))
	}

	return imaging.Resize(imaging.Crop(i, sliceRect), r.Dx(), r.Dy(), imaging.Lanczos)
}
开发者ID:srinathh,项目名称:mobilehtml5app,代码行数:16,代码来源:static.go


示例20: handlePOST

func (h *ImgHandler) handlePOST(w http.ResponseWriter, req *http.Request) {
	s := MgoSession.Copy()
	defer s.Close()

	name, path := h.convertPath(req.URL.Path)
	document, _ := new(Document).Find(s, name, path)
	document.Name = name
	document.Path = path

	origin, format, err := image.Decode(req.Body)
	if err != nil {
		log.Panicln(err)
		io.WriteString(w, err.Error())
		return
	}

	// image is larger than the specified stored size, we need to resize it
	var img image.Image
	if (Configuration.StoredSize.Width > 0 && origin.Bounds().Dx() > Configuration.StoredSize.Width) ||
		(Configuration.StoredSize.Height > 0 && origin.Bounds().Dy() > Configuration.StoredSize.Height) {
		img = imaging.Resize(origin, Configuration.StoredSize.Width, Configuration.StoredSize.Height, imaging.CatmullRom)
	} else {
		img = origin
	}

	buf := new(bytes.Buffer)
	err = h.writeImage(buf, img, format)
	if err != nil {
		log.Panicln(err)
		io.WriteString(w, err.Error())
		return
	}
	document.Binary = buf.Bytes()

	contentType := req.Header.Get("Content-Type")
	if contentType != "" {
		document.ContentType = contentType
	}

	err = document.Save(s)
	if err != nil {
		log.Panicln(err)
		io.WriteString(w, err.Error())
	} else {
		io.WriteString(w, "stored\n")
	}
}
开发者ID:huayuxian,项目名称:imongo,代码行数:47,代码来源:handler.go



注:本文中的github.com/disintegration/imaging.Resize函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang imaging.Rotate180函数代码示例发布时间:2022-05-23
下一篇:
Golang imaging.Open函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap