how to speed up text annotation to tiff files

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
eltato

how to speed up text annotation to tiff files

Post by eltato »

Hello.

I'm trying to put some text on a tiff file and it takes around 5-6 seconds. Is there a way to speed up the process?
I execute the next command:

Code: Select all

convert aaa.tif -font Arial -pointsize 100 -gravity West -draw "text 0,0 'hola'" -monitor -compress Group4 -define quantum:polarity=min-is-white stamp.tif
I use the -monitor swith so I can see that it takes more time in Dither image colors: process. Is there anyway of disable dithering? I've tried +dither but it takes the same time.

The input tiff file is like this:

Code: Select all

/opt/imagemagick/bin/identify -verbose aaa.tif
Image: aaa.tif
  Format: TIFF (Tagged Image File Format)
  Class: DirectClass
  Geometry: 2479x3508+0+0
  Resolution: 300x300
  Print size: 8.26333x11.6933
  Units: PixelsPerInch
  Type: Bilevel
  Base type: Bilevel
  Endianess: LSB
  Colorspace: RGB
  Depth: 1-bit
  Channel depth:
    gray: 1-bit
  Channel statistics:
    gray:
      min: 0 (0)
      max: 1 (1)
      mean: 0.763653 (0.763653)
      standard deviation: 0.424837 (0.424837)
      kurtosis: -0.45943
      skewness: -1.2412
  Histogram:
   6640984: (255,255,255) #FFFFFF white
   2055348: (  0,  0,  0) #000000 black
  Rendering intent: Undefined
  Interlace: None
  Background color: white
  Border color: rgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Page geometry: 2479x3508+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Group4
  Orientation: TopLeft
  Properties:
    create-date: 2009-04-08T16:55:47+02:00
    modify-date: 2009-04-08T16:55:47+02:00
    signature: 3d9f8b09ba3d3deb80b5d89ed0960e89474030b7c22fba854ea9428ce29f1a03
    tiff:document: 0000000001.tif
    tiff:rows-per-strip: 3508
    tiff:software: ImageMagick 6.5.1-0 2009-04-06 Q16 http://www.imagemagick.org
    tiff:timestamp: 2009:01:21 10:56:40
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 509kb
  Number pixels: 8.293mb
  Version: ImageMagick 6.5.1-0 2009-04-06 Q16 http://www.imagemagick.org
I've compiled ImageMagick 6.5.1-0 version.


Thanks in advance.
eltato

Re: how to speed up text annotation to tiff files

Post by eltato »

Anybody?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: how to speed up text annotation to tiff files

Post by magick »

ImageMagick is not optimized for processing 1-bit images. Text annotation adds shading to your image so it must be color reduced afterwards to recreate a monochome image. Color reduction is rather slow in ImageMagick. You can try thresholding which is quite fast but it may not return the results you are looking for.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: how to speed up text annotation to tiff files

Post by anthony »

ordered dithing is also faster than the normal color reduction processing.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
eltato

Re: how to speed up text annotation to tiff files

Post by eltato »

Hi and thank you very much for your answers.
Adding the option -threshold 50% the process is much faster.
Without thresholding:

Code: Select all

time /opt/imagemagick/bin/convert aaa.tif -font Arial -pointsize 100 -gravity West -draw "text 0,0 'hola'" -compress Group4 -define quantum:polarity=min-is-white stamp.tif

real    0m5.506s
user    0m4.944s
sys     0m0.552s
With thresholding:

Code: Select all

time /opt/imagemagick/bin/convert aaa.tif -font Arial -pointsize 100 -gravity West -draw "text 0,0 'hola'" -compress Group4 -define quantum:polarity=min-is-white -threshold 50% stamp.tif

real    0m0.579s
user    0m0.224s
sys     0m0.348s
Almost ten times faster. :)
The result image is quite good and is enough for me at the moment.
Post Reply