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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
mkeveney
Posts: 5
Joined: 2019-04-19T16:44:40-07:00
Authentication code: 1152

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

Post 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>")
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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
snibgo's IM pages: im.snibgo.com
mkeveney
Posts: 5
Joined: 2019-04-19T16:44:40-07:00
Authentication code: 1152

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

Post 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!
mkeveney
Posts: 5
Joined: 2019-04-19T16:44:40-07:00
Authentication code: 1152

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

Wand may still be using that structure. So do post to the Wand GIT page Issues.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

When posting code in this forum, it is best to highlight your text, then select the </> (for code) button.
Post Reply