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

Add simple (and naive) implementation of pixelate filter #224

Merged
merged 6 commits into from
Jan 14, 2022

Conversation

Elad-Laufer
Copy link
Contributor

@Elad-Laufer Elad-Laufer commented Nov 23, 2021

A pixelate filter based on simple resize steps.

@coveralls
Copy link

coveralls commented Nov 23, 2021

Coverage Status

Coverage decreased (-0.1%) to 75.493% when pulling e87df13 on wix-incubator:pixelate into 910ca57 on davidbyttow:master.

vips/image.go Outdated
@@ -1180,6 +1180,40 @@ func (r *ImageRef) ModulateHSV(brightness, saturation float64, hue int) error {
return nil
}

// Pixelate applies a simple pixelate filter to the image
func (r *ImageRef) Pixelate(factor float64) error {
Copy link
Owner

Choose a reason for hiding this comment

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

do you want to assert that factor > 0?

Copy link
Owner

Choose a reason for hiding this comment

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

I feel like this is a little specific to hang on ImageRef type.

How would you feel about making this a utility method that takes in (and maybe return a new ImageRef)? Or it can modify in place

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I placed it under ImageRef is that to my understanding the same effect can be archived by with a single pass on the image, and I didn't want to end up with two APIs that do the same.

Copy link
Owner

Choose a reason for hiding this comment

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

Sorry, all I'm saying is that we could easily do:

func Pixelate(image *ImageRef, factor float64) error {
  // your code
}

I mean, I know there's a bunch of things on ImageRef already, I do wish it were more minimal and the "modifiers" of it were separate functions. WDYT? Let me know and we can merge

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, this way we won't end up with BC (issues) later on.

Copy link
Owner

Choose a reason for hiding this comment

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

BC? (bloated code)? (maybe im being dumb, it's early here in Paris)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Backwards Compatible :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, all I'm saying is that we could easily do:

func Pixelate(image *ImageRef, factor float64) error {
  // your code
}

I mean, I know there's a bunch of things on ImageRef already, I do wish it were more minimal and the "modifiers" of it were separate functions. WDYT? Let me know and we can merge

Implemented

@Elad-Laufer Elad-Laufer marked this pull request as ready for review January 12, 2022 13:16
@davidbyttow davidbyttow merged commit 423eb69 into davidbyttow:master Jan 14, 2022
@Elad-Laufer Elad-Laufer deleted the pixelate branch August 3, 2022 15:26
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.

None yet

3 participants