Page 1 of 1

Resize 'blur' option not working on 'wand' library.

Posted: 2019-04-19T17:42:27-07:00
by mkeveney
First of all, i'm not sure I'm in the right place

I'm trying to use the Python 'Wand' binding: http://docs.wand-py.org/en/0.5.2/
Is this the right forum?

To get my feet wet, I've ported this script to python:

http://old.dylanbeattie.net/magick/filters/result.html

Unfortunately, the 'blur' parameter on resize seems to have no effect. All images for a given filter are a binary match to each other.

Actually, I was surprised to see 'blur' as a parameter to resize().. since that doesn't seem to reflect the commandline version of ImageMagick.
This page: https://imagemagick.org/script/command- ... essing.php

...identifies -blur as an image _Operator_ while -filter is an image _Setting_. I'd expect settings to be surfaced as parameters and operators as methods. Maybe that's just me.

Am I missing something?

Code: Select all

# Implementing something like http://old.dylanbeattie.net/magick/filters/result.html
# to test various imagemagick filters
#

from wand.image import Image
from wand.image import FILTER_TYPES

# infile = "gray.png"
infile = "face.jpg"

preamble = """
<html>
<head>
<title>ImageMagick Filters</title>
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>ImageMagick Resize Filters</h1>
<p>This page demonstrates the results of resampling three images using the various resize filters and blur settings available in ImageMagick, and the file size of the resulting thumbnail images. Click the image filename at the top of each section to see the fullsize image.</p>
<p>based on this <a href="filters.pl">Perlmagick script</a> with many thanks to original author</p>
<hr>
<h1>The Results</h1>
"""

#
#
def createHTML():

    # doc header
    print(preamble)

    # table header
    print("<table cellpadding=\"5\" border=\"1\">")
    print("<tr><td>Filter:</td>")
    colcount = 1
    blur = 0.125
    while(blur <= 4):
        print("<td>Blur {}</td>".format(blur))
        blur = blur * 2
        colcount += 1
    print("</tr>")

    # original image line
    print('<tr><td colspan={}><a href="{}"/a> (Click for original image)</td></tr>'.format(colcount, infile, infile))

    # the table
    with Image(filename = infile) as imgOrg:
        for filter in FILTER_TYPES:
            print("<tr><td>{}</td>".format(filter));
            blur = 0.125
            while(blur <= 4):
                blur = blur * 2
                with imgOrg.clone() as img:
                    img.resize(128, 128, filter, blur)
                    newfn="img/f_{}_b_{}_org_{}".format(filter, blur, infile)
                    img.save(filename = newfn)
                    print('<td><img src="{}"></td>'.format(newfn))
            print("</tr>")

    # finish doc
    print("</td>")
    print("</body>")

Re: Resize 'blur' option not working on 'wand' library.

Posted: 2019-04-19T18:04:07-07:00
by fmw42
The forum to which you posted was not for Python. There is no Python forum here. But I have moved your question to the Users forum in case someone here might be using it.

I would suggest posting your issue directly to the Python Wand GIT directory at https://github.com/emcconville/wand

With regard to blur on resize, see filter support at https://imagemagick.org/Usage/filter/ and https://imagemagick.org/Usage/filter/nicolas/. There are many resampling methods that can be used with -resize and -distort resize. Some allow the shape of the kernel to be adjusted via -define filter:support and -define filter:blur. Others do not have such control.

Re: Resize 'blur' option not working on 'wand' library.

Posted: 2019-04-19T18:08:44-07:00
by snibgo
Your question is about a Python interface, not the C MagickWand interface, but there is no IM Python forum.

I think an old interface to IM had "blur" as a parameter to "resize". But that changed long ago, so now we have "-define filter:blur=n", as an expert setting that is rarely used. See http://www.imagemagick.org/script/comma ... php#define

Re: Resize 'blur' option not working on 'wand' library.

Posted: 2019-04-19T18:58:47-07:00
by mkeveney
> The forum to which you posted was not for Python....
Thanks for the links; I'll read up and redirect my questions.
> I think an old interface to IM had "blur" as a parameter to "resize"...
I suspected something like that. Thanks for the info!

Re: Resize 'blur' option not working on 'wand' library.

Posted: 2019-04-19T19:01:33-07:00
by mkeveney
By the way.. the code in my initial post lost it's indenting so it won't work in Python, in case anyone tries.

Re: Resize 'blur' option not working on 'wand' library.

Posted: 2019-04-19T19:01:58-07:00
by fmw42
Wand may still be using that structure. So do post to the Wand GIT page Issues.

Re: Resize 'blur' option not working on 'wand' library.

Posted: 2019-04-19T19:02:43-07:00
by fmw42
When posting code in this forum, it is best to highlight your text, then select the </> (for code) button.