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

Adds Recomb for ImageRef #377

Merged
merged 3 commits into from
Nov 10, 2023
Merged

Adds Recomb for ImageRef #377

merged 3 commits into from
Nov 10, 2023

Conversation

n0vad3v
Copy link
Contributor

@n0vad3v n0vad3v commented Aug 9, 2023

This PR will add support for vips_recomb on ImageRef, will provide similar functionality as sharp does(https://sharp.pixelplumbing.com/api-operation#recomb)

Sharp example:

sharp(input)
  .recomb([
   [0.3588, 0.7044, 0.1368],
   [0.2990, 0.5870, 0.1140],
   [0.2392, 0.4696, 0.0912],
  ])
  .raw()
  .toBuffer(function(err, data, info) {
    // data contains the raw pixel data after applying the matrix
    // With this example input, a sepia filter has been applied
  });

Go example after this PR merged:

package main

import (
	"fmt"
	"os"

	"github.com/davidbyttow/govips/v2/vips"
)

func main() {
	vips.Startup(nil)
	defer vips.Shutdown()

	img, _ := vips.NewImageFromFile("test.png")
	matrix := [][]float64{
		{0.3588, 0.7044, 0.1368},
		{0.2990, 0.5870, 0.1140},
		{0.2392, 0.4696, 0.0912},
	}

	err := img.Recomb(matrix)
	if err != nil {
		fmt.Println(err)
	}
	image1bytes, _, _ := img.ExportPng(vips.NewPngExportParams())
	_ = os.WriteFile("experiment.png", image1bytes, 0644)

}

test.png
test

experiment.png
experiment

BennyThink and others added 3 commits August 8, 2023 22:05
A new function add img.Recomb support has been added to the ImageRef structure
Copy link
Collaborator

@tonimelisma tonimelisma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tonimelisma tonimelisma merged commit dbf5fb2 into davidbyttow:master Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants