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

Bindings for compression quality and stripping #23

Merged
merged 3 commits into from May 27, 2012
Merged

Bindings for compression quality and stripping #23

merged 3 commits into from May 27, 2012

Conversation

dvukolov
Copy link
Contributor

In the course of a local web project I added a couple of bindings for manipulating the resulting image file size: getting and setting image compression quality, as well as stripping the image of comments and profile data to reduce the file size. In my case this was extremely useful for processing jpeg images before uploading them to a web server.

@dahlia
Copy link
Collaborator

dahlia commented May 27, 2012

Thanks for your code. It is almost fine, but some trivial things outstand. I will comment to these things.

result = library.MagickStripImage(self.wand)
if not result:
self.raise_exception()

Copy link
Collaborator

Choose a reason for hiding this comment

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

How can we test Image.strip() method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without actually looking into the presence of profiles and comments in an image, it's possible to simply check the file size before and after stripping. The beach.jpg from assets is a good example, containing Exif data and color profile. Like this:

@tests.test
def strip():
    """Strips the image of all profiles and comments."""
    with Image(filename=asset('beach.jpg')) as img:
        strio = StringIO.StringIO()
        img.save(file=strio)
        len_unstripped = strio.tell()
        strio.truncate(0)
        img.strip()
        img.save(file=strio)
        len_stripped = strio.tell()
        assert len_unstripped > len_stripped

@dahlia
Copy link
Collaborator

dahlia commented May 27, 2012

@dvukolov I will merge it into master when you make a new commit. 👍

dahlia added a commit that referenced this pull request May 27, 2012
Bindings for compression quality and stripping
@dahlia dahlia merged commit 8b1d86d into emcconville:master May 27, 2012
@dahlia
Copy link
Collaborator

dahlia commented May 27, 2012

Thanks for your effort. I merged it. ☀️

dahlia added a commit that referenced this pull request May 27, 2012
@dahlia
Copy link
Collaborator

dahlia commented May 27, 2012

See also the changelog: http://dahlia.github.com/wand/changes.html#version-0-2-0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants