[fpc-pascal] Why is FPImage dog slow in reading jpeg's?

Ben Smith ben.smith.lists at gmail.com
Mon May 30 16:08:10 CEST 2011


I wrote this console utility app in 5 minutes. All it is supposed to
do, is iterate over *.jpg images (65 at the moment) in a folder (no
recursive searches), and generate a snipped of HTML that I need to
paste into my wives website.

I first thought my utility app is in some recursive loop or something
because the output didn't appear instantly - like I thought it would.

I added some debug output between the generate HTML. To my surprise
the FPImage code reading a 35Kb jpg file takes +- 8 seconds and a 65KB
file takes +- 30 seconds - on a Quad Core machine! WTF???

Is this normal? Is FPImage really that slow reading small roughly
650x450 pixel jpg images?  Or am I doing something unbelievably
stupid? :-/

The reason I'm reading in the jpg files is so I can get their Width
and Height values. Avg. jpeg file sizes are between 35-45KB, and
largest file size is 65KB.

Here is the relevant code snippet....

  imgreader: TFPReaderJPEG;
  stream: TFileStream;


  writeln('processing file: ', filelist[i]);
  stream := TFileStream.Create(filelist[i], fmOpenRead);
  imgreader := TFPReaderJPEG.Create;
  writeln(2, FormatDateTime(' hh:mm:ss.zz', Now) + '  (start reading)');
  img := imgreader.ImageRead(stream, nil);
  writeln(3, FormatDateTime(' hh:mm:ss.zz', Now) + '  (done)');

Here is the program output... Note the timestamps between start
reading and done reading (lines marked with '2' and '3').

-------------------[ start ]---------------------------
$ ./project1 img/babies/full
Finished search. Found 65 matches
<div id="thumbnails">
<table cellspacing="10">
<tr align="center" valign="middel">	<!--  Row starts  -->
processing file: img/babies/full/babies.01.jpg
2 16:00:30.210  (start reading)
3 16:00:38.338  (done)
<img src="img/babies/full/babies.01.jpg" alt="" id="screen1"
class="imglarge" onmouseout="reducethumb(1); return false;"
onclick="reducethumb(1); return false;">
<img src="img/babies/thumbs/babies.01.jpg" alt="" class="imgsmall"
id="thumb1" onclick="expandthumb(1, 650, 413);">
<tr align="center" valign="middel">	<!--  Row starts  -->
processing file: img/babies/full/babies.02.jpg
2 16:00:38.338  (start reading)
3 16:01:10.447  (done)
<img src="img/babies/full/babies.02.jpg" alt="" id="screen2"
class="imglarge" onmouseout="reducethumb(2); return false;"
onclick="reducethumb(2); return false;">
<img src="img/babies/thumbs/babies.02.jpg" alt="" class="imgsmall"
id="thumb2" onclick="expandthumb(2, 650, 435);">
<tr align="center" valign="middel">	<!--  Row starts  -->
processing file: img/babies/full/babies.03.jpg
2 16:01:10.447  (start reading)
3 16:01:28.859  (done)
<img src="img/babies/full/babies.03.jpg" alt="" id="screen3"
class="imglarge" onmouseout="reducethumb(3); return false;"
onclick="reducethumb(3); return false;">
<img src="img/babies/thumbs/babies.03.jpg" alt="" class="imgsmall"
id="thumb3" onclick="expandthumb(3, 405, 650);">
<tr align="center" valign="middel">	<!--  Row starts  -->
processing file: img/babies/full/babies.04.jpg
2 16:01:28.859  (start reading)

-------------------[ end ]---------------------------



More information about the fpc-pascal mailing list