Drawing on bilevel PNG is (very) slow

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
myicq
Posts: 29
Joined: 2012-04-11T04:23:21-07:00
Authentication code: 8675308

Drawing on bilevel PNG is (very) slow

Post by myicq »

Related to my previous post (viewtopic.php?f=1&t=24069), I am making experiments with annotation and drawing on the image.

In principle all works. But as soon as I work with monochrome (bilevel) images, ImageMagick becomes extremely slow. I have an Intel i7, Win7 yet drawing a straight line in a 48000 x 1200 pixel bilevel PNG still takes the better part of 30 seconds.

This will take a second or two and creates a 4bpp PNG

Code: Select all

convert -size 48000x1200 xc:white -fill black -stroke black -strokewidth 50 -draw "line 0,0 1000,300" normal.png
This takes around 30 seconds:

Code: Select all

convert normal.png -type bilevel  mybilevel.png
What can I do to speed up drawing ? Happy to try everything.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Drawing on bilevel PNG is (very) slow

Post by snibgo »

Your first command reduces the staircase effect of diagonal lines with carefully-selected shades of gray, known as "antialiasing". Your second command then carefully removes all the grey.

Both commands run much faster if you don't create the grey in the first place. Turn off antialiasing by placing "+antialiasing" at the start of the first command.
snibgo's IM pages: im.snibgo.com
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Drawing on bilevel PNG is (very) slow

Post by magick »

You can try one of the threshold options. They are lightening fast (e.g. -threshold).
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Drawing on bilevel PNG is (very) slow

Post by snibgo »

Another thing: you may find that Q8 is quicker than Q16.
snibgo's IM pages: im.snibgo.com
Post Reply