Page 1 of 1

PowerShell and Magick.NET Write performance advice

Posted: 2019-04-02T17:49:40-07:00
by Batman11
Hi, Using .NEt and PowerShell, I'm trying to write a rectangle on a bunch of small Tif images (each size around 10k). Seems to be working except performance is slow when saving the Tif image to disk (Using $IMG.WRITE). It takes about half a second or more to write it out. Was hoping to bring this down a bit.
Any advice on increasing performance of the write? Thanks

Code: Select all

GCI "C:\users\Allan\desktop\\images" | ForEach-Object {

    $img = [ImageMagick.MagickImage]::new($_)

    $Draw = [ImageMagick.Drawables]::new()
    $Draw.FillColor([ImageMagick.MagickColors]::Blue)
    
    $draw.Rectangle(0,0,780,245)}
    
    $Draw.Draw($img)
    
   $FileOut ="C:\users\allan\desktop\images\x$_"
    $img.Write($FileOut)
 }
I measured the write command ($img.Write($FileOut)) and it takes around .7 of a second to write it out.
I'm trying other methods and they write at around .2 to .3 of a second. That doesn't sound like much but those processes already take about 2 hours to do.
Thanks