ropensci / magick

Magic, madness, heaven, sin
https://docs.ropensci.org/magick
Other
461 stars 66 forks source link

compose_args in image_composite #347

Open raymondben opened 2 years ago

raymondben commented 2 years ago

Hi, not sure what is going on here. I am trying to get the ChangeMask operator through image_composite to respect the fuzz argument. But imc1 and imc2 here are identical:

im1 <- image_read("logo:")
im2 <- image_blur(im1, radius = 3, sigma = 3)

imc1 <- magick::image_composite(im2, im1, operator = "ChangeMask", compose_args = "-fuzz 10%")
imc2 <- magick::image_composite(im2, im1, operator = "ChangeMask", compose_args = "-fuzz 90%")

Yet when I do it from the command line, it works:

f1 <- tempfile(fileext = ".gif"); image_write(im1, f1)
f2 <- tempfile(fileext = ".gif"); image_write(im2, f2)
fout1 <- tempfile(fileext = ".gif")
sys::exec_wait("convert", c(f2, f1, "-compose", "ChangeMask", "-fuzz", "10%", "-composite", fout1))
fout2 <- tempfile(fileext = ".gif")
sys::exec_wait("convert", c(f2, f1, "-compose", "ChangeMask", "-fuzz", "90%", "-composite", fout2))
browseURL(fout1)
browseURL(fout2)

(fout1 and fout2 are visually different, as I would expect). Any ideas? Maybe related to #212

Sysinfo: Ubuntu 20.04.4 LTS

> packageVersion("magick")
[1] ‘2.7.3.9000’

(Happens with both 2.7.3 and the current dev version 2.7.3.9000)

> magick_config()
$version
[1] ‘6.9.10.23’

$modules
[1] TRUE

$cairo
[1] FALSE

$fontconfig
[1] TRUE

$freetype
[1] TRUE

$fftw
[1] TRUE

$ghostscript
[1] FALSE

$heic
[1] FALSE

$jpeg
[1] TRUE

$lcms
[1] TRUE

$libopenjp2
[1] FALSE

$lzma
[1] TRUE

$pangocairo
[1] TRUE

$pango
[1] TRUE

$png
[1] TRUE

$raw
[1] FALSE

$rsvg
[1] FALSE

$tiff
[1] TRUE

$webp
[1] TRUE

$wmf
[1] TRUE

$x11
[1] TRUE

$xml
[1] TRUE

$`zero-configuration`
[1] FALSE

$threads
[1] 8
raymondben commented 2 years ago

Urg. OK, I think the composite method being used here is equivalent to the composite command line operator, not the convert ... -composite form, so my comparison of magick::image_composite to the convert command line call isn't really valid. So my question remains, but my suspicion is that the composite method simply doesn't allow the fuzz argument.