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 recolor to make Pop Art #108

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

beartung
Copy link
Contributor

@beartung beartung commented May 3, 2013

I want to make a pop art photo with wand, but not found any function to manipulate pixels.

The example is here: https://github.com/beartung/pop_art_wand

looks like this:

test_1886982_dec

@beartung
Copy link
Contributor Author

beartung commented May 3, 2013

@dahlia is imagemagick thread safe? If so, I can make a parrel version to do this to faster.

@beartung beartung mentioned this pull request May 3, 2013
@dahlia
Copy link
Collaborator

dahlia commented May 3, 2013

Thanks for your efforts. The most things are fine, but…

  • Why is color_func optional? (It even does nothing when color_func is None.)
  • **kwargs seem unnecessary. You can bind fixed arguments to color_func using functools.partial().
  • It would be better if color_func returns a Color instead of a string.
  • Check to make sure color_func is callable. Raise TypeError otherwise.

@dahlia is imagemagick thread safe? If so, I can make a parrel version to do this to faster.

On Mac at least it’s not thread safe.

@@ -672,6 +672,29 @@ def __getitem__(self, idx):
return self[:, idx]
raise TypeError('unsupported index type: ' + repr(idx))

def recolor(self, color_func):
if not color_func or not callable(color_func):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we don’t need to check not color_func. ;-)

@dahlia
Copy link
Collaborator

dahlia commented May 3, 2013

Adjustments are find! Could you write some docstring for this method?

@beartung
Copy link
Contributor Author

beartung commented May 3, 2013

😰

@dahlia
Copy link
Collaborator

dahlia commented May 3, 2013

It takes very long time for me… how can we improve its performance?

@beartung
Copy link
Contributor Author

beartung commented May 4, 2013

en... better but not enough, I am working on a c version 😟

@beartung
Copy link
Contributor Author

beartung commented May 7, 2013

@dahlia I have test the c version, only about 2 seconds to dispose of 2102x2102 jpg

using this code:

view = NewWandView(wand);
if (view == (WandView *) NULL) ThrowWandException(wand);
status = UpdateWandViewIterator(view, recolor, (void *)NULL);
if (status == MagickFalse) ThrowWandException(wand);
view = DestroyWandView(view);

full code https://github.com/beartung/pop_art_wand/blob/master/pop_art.c

I will try this method in python later...

@dahlia
Copy link
Collaborator

dahlia commented Jun 23, 2013

We will go to CFFI from ctypes, and then this part could be written in C.

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

2 participants