Skip to content

Resize using FilterType::Lanczos3 produces unexpected artifacts #1116

@ojensen5115

Description

@ojensen5115

This happens when using image = "0.22.3".

Begin with a 75x70 reference image edge.png:
edge

Resize edge.png to 45x42 with the Lanczos3 filter using ImageMagic to produce edge-im.png:
edge_im

Resize edge.png to 45x42 with the Lanczos3 filter using image-rs to produce edge-imagers.png:
edge-imagers

Expected

Images edge-im.png and edge-imagers.png should look the same.

Actual behaviour

The image produced by image-rs contains a significant artifacting around the edge. This is most easily seen in the upper half of the resulting images. I've zoomed in on the same section of both images here:

edge-im.png:
edge-im-zoom

edge-imagers.png
edge-imagers-zoom

Reproduction steps

To resize the image using ImageMagick, I used the following command:
convert edge.png -resize 45x42 -filter Lanczos edge_im.png

To resize the image using image-rs, I used the following code:

extern crate image;

use image::imageops::FilterType::Lanczos3;

fn main() {
    let mut image = image::open("edge.png").unwrap().to_rgba();
    image = image::imageops::resize(&image, 45, 42, Lanczos3);
    match image.save("edge-imagers.png") {
        Ok(()) => eprintln!("image written"),
        Err(e) => eprintln!("failed to write image: {}", e),
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions