Skip to content
New issue

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

Fix typos and shadowing #241

Merged
merged 1 commit into from
Jan 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions vips/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ import (
"unsafe"
)

// PreMultiplicationState stores the premultiplication band format of the image
// PreMultiplicationState stores the pre-multiplication band format of the image
type PreMultiplicationState struct {
bandFormat BandFormat
}

// ImageRef contains a libvips image and manages its lifecycle. You need to
// close an image when done or it will leak
// ImageRef contains a libvips image and manages its lifecycle.
type ImageRef struct {
// NOTE: We keep a reference to this so that the input buffer is
// never garbage collected during processing. Some image loaders use random
Expand Down Expand Up @@ -455,8 +454,8 @@ func (r *ImageRef) Copy() (*ImageRef, error) {
// XYZ creates a two-band uint32 image where the elements in the first band have the value of their x coordinate
// and elements in the second band have their y coordinate.
func XYZ(width, height int) (*ImageRef, error) {
image, err := vipsXYZ(width, height)
return &ImageRef{image: image}, err
vipsImage, err := vipsXYZ(width, height)
return &ImageRef{image: vipsImage}, err
}

// Identity creates an identity lookup table, which will leave an image unchanged when applied with Maplut.
Expand All @@ -468,18 +467,18 @@ func Identity(ushort bool) (*ImageRef, error) {

// Black creates a new black image of the specified size
func Black(width, height int) (*ImageRef, error) {
image, err := vipsBlack(width, height)
return &ImageRef{image: image}, err
vipsImage, err := vipsBlack(width, height)
return &ImageRef{image: vipsImage}, err
}

func newImageRef(vipsImage *C.VipsImage, format ImageType, buf []byte) *ImageRef {
image := &ImageRef{
imageRef := &ImageRef{
image: vipsImage,
format: format,
buf: buf,
}
runtime.SetFinalizer(image, finalizeImage)
return image
runtime.SetFinalizer(imageRef, finalizeImage)
return imageRef
}

func finalizeImage(ref *ImageRef) {
Expand All @@ -489,7 +488,7 @@ func finalizeImage(ref *ImageRef) {

// Close manually closes the image and frees the memory. Calling Close() is optional.
// Images are automatically closed by GC. However, in high volume applications the GC
// can't keep up with the amount of memory so you might want to manually close the images.
// can't keep up with the amount of memory, so you might want to manually close the images.
func (r *ImageRef) Close() {
r.lock.Lock()

Expand Down Expand Up @@ -609,7 +608,7 @@ func (r *ImageRef) Interpretation() Interpretation {
return Interpretation(int(r.image.Type))
}

// ColorSpace returns the interpreptation of the current color space. Alias to Interpretation().
// ColorSpace returns the interpretation of the current color space. Alias to Interpretation().
func (r *ImageRef) ColorSpace() Interpretation {
return r.Interpretation()
}
Expand Down Expand Up @@ -1050,7 +1049,7 @@ func (r *ImageRef) Divide(denominator *ImageRef) error {
return nil
}

// Linear passes an image through a linear transformation (ie. output = input * a + b).
// Linear passes an image through a linear transformation (i.e. output = input * a + b).
// See https://libvips.github.io/libvips/API/current/libvips-arithmetic.html#vips-linear
func (r *ImageRef) Linear(a, b []float64) error {
if len(a) != len(b) {
Expand Down Expand Up @@ -1120,7 +1119,7 @@ func (r *ImageRef) ExtractArea(left, top, width, height int) error {
}

// RemoveICCProfile removes the ICC Profile information from the image.
// Typically browsers and other software assume images without profile to be in the sRGB color space.
// Typically, browsers and other software assume images without profile to be in the sRGB color space.
func (r *ImageRef) RemoveICCProfile() error {
out, err := vipsCopyImage(r.image)
if err != nil {
Expand Down Expand Up @@ -1391,7 +1390,7 @@ func (r *ImageRef) Resize(scale float64, kernel Kernel) error {
return r.ResizeWithVScale(scale, -1, kernel)
}

// ResizeWithVScale resizes the image with both horizontal as well as vertical scaling.
// ResizeWithVScale resizes the image with both horizontal and vertical scaling.
// The parameters are the scaling factors.
func (r *ImageRef) ResizeWithVScale(hScale, vScale float64, kernel Kernel) error {
err := r.PremultiplyAlpha()
Expand Down Expand Up @@ -1495,7 +1494,7 @@ func (r *ImageRef) Similarity(scale float64, angle float64, backgroundColor *Col
return nil
}

// SmartCrop will crop the image based on interestingness factor
// SmartCrop will crop the image based on interesting factor
func (r *ImageRef) SmartCrop(width int, height int, interesting Interesting) error {
out, err := vipsSmartCrop(r.image, width, height, interesting)
if err != nil {
Expand Down