github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/image/jpeg/writer.go (about)

     1  // Copyright 2011 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package jpeg
     6  
     7  import (
     8  	"github.com/shogo82148/std/image"
     9  	"github.com/shogo82148/std/io"
    10  )
    11  
    12  // DefaultQualityは、デフォルトの品質エンコーディングパラメータです。
    13  const DefaultQuality = 75
    14  
    15  // Optionsは、エンコーディングパラメータです。
    16  // Qualityは1から100までの範囲で、高いほど良いです。
    17  type Options struct {
    18  	Quality int
    19  }
    20  
    21  // Encodeは、与えられたオプションでJPEG 4:2:0ベースラインフォーマットでImage mをwに書き込みます。
    22  // nilの *[Options] が渡された場合、デフォルトのパラメータが使用されます。
    23  func Encode(w io.Writer, m image.Image, o *Options) error