Annotation on tiff 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
Aparna More

Annotation on tiff is very slow

Post by Aparna More »

Hello,

I m a new user of ImageMagick .I need to add text to image at the bottom.
So i m using the following command :

convert inputTiffName -gravity SouthEast -font helvetica -pointsize 41 -annotate 'Stamp On Tiff' OutputTiffName

I have used the sh file to apply stamp on all tiffs in the given folder

Stamping.sh

date >> StampingLog.txt
for i in `ls`;do convert /home/dev/Aparna/SinglePage_Tiff_Out_GS/$i -gravity SouthEast -font helvetica -pointsize 41 -annotate 'Stamp On Tiff' /home/dev/Aparna/Stamped_Without_Resize_Tiff/$i; done
date >> StampingLog.txt

But the process is very slow . It is taking 2 hrs and 30 min to apply stamp on 1000 tiffs where as other stamping tool is taking just a 10 min for the same process .

Do i need to use any flags to improve the performance ?

Please guide me in the right direction .


Regards
Aparna
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Annotation on tiff is very slow

Post by snibgo »

IM is a general-purpose tool, and can be slower than more specialist single-purpose programs. But 9 seconds per conversion is very slow. How large are the images? Can you post one? What version IM do you use?
snibgo's IM pages: im.snibgo.com
Aparna More

Re: Annotation on tiff is very slow

Post by Aparna More »

Thanks for the reply.
I m using ImageMagick 6.6.1-7.
Images are tiffs (-sDEVICE=tiffg4) created from PDF with 300 dpi , so its pixel size is 2550x3300 .
I have tried -threshold 50% option.
Adding the option -threshold 50% the process is much faster and the result image is quite good.

Before adding threshold - Time required - 2 hrs and 30 min
After adding threshold - Time required - 14 min

Do anybody have any idea what happens with image when we set threshold value ?
Do it degrade the image quality ?
If not can i reduce the threshold value to get more faster response ?

Thanks in advance .
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Annotation on tiff is very slow

Post by snibgo »

On my Windows7 laptop, IM 6.6.0-8, where red.tif is 2550x3300, this takes 0.08 seconds (so 1 minute 20 seconds for 1000):

Code: Select all

convert red.tif -gravity SouthEast -font c:\windows\fonts\arial.ttf -pointsize 41 -annotate 0 "Stamp on tiff" reda.tif
It is difficult to comment further unless you provide a sample that is taking 9 seconds.
snibgo's IM pages: im.snibgo.com
Aparna More

Re: Annotation on tiff is very slow

Post by Aparna More »

Thank you so much for replies.

I m working on Open SUSE 11.2 .
Time required :

time convert ./1.tiff -gravity SouthEast -font helvetica -pointsize 41 -annotate 0+2 "Stamp on tiff" ./2.tiff
real 0m8.176s
user 0m10.829s
sys 0m0.472s

Here is the sample file :

http://docs.google.com/leaf?id=0B7LlXii ... NDc1&hl=en


As soon as i used this flag -threshold 50% it increase the performance tremendously .

Do you have any idea What happens with image when flag -threshold 50% is used ?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Annotation on tiff is very slow

Post by snibgo »

This is very strange. On IM 6.6.0-8 Windows 7:

Code: Select all

convert sample.tiff -gravity SouthEast -font c:\windows\fonts\arial.ttf -pointsize 41 -annotate 0+2 "Stamp on tiff" 2a.tiff <-- takes about 12 seconds

convert sample.tiff -gravity SouthEast -font c:\windows\fonts\arial.ttf -pointsize 41 -annotate 0+2 "Stamp on tiff" -threshold 50% 2b.tiff <-- takes less than 1 second
sample.tiff is bilevel. Output 2b.tiff is bilevel, which is reasonable. But output 2a.tiff is also bilevel, where I would expect grayscale anti-aliasing around the characters.

I would expect the thresholding to remove the anti-aliasing, so reducing the image quality slightly, and taking some time to do so. But the two outputs are almost identical and the thresholding dramatically improves performance.

The workaround for Aparna More is, of course, to use thresholding.

Perhaps someone with more knowledge about internals could comment.
snibgo's IM pages: im.snibgo.com
Post Reply