Solved

Some Image questions.

Posted on 2004-08-24
5
151 Views
Last Modified: 2010-04-05

   How can I take a list of pictures from folder where every image (which are jpeg) is 1600x1200 and resize it to lets say 800x600 ??
   I nead to create a program to run through several folders and resize my images so they will be managable on the web.

     Regards,
       Tomas Helgi
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 300 total points
ID: 11879410
well, i have not the time for a sample, but i suggest following flow

- iterate through the files via findfirst/findnext
- open each file and lookup the metrics
- if to shrink
  - assign your jpeg to a bmp-object
  - create a secondary empty bmp-object, adjust there the needed metrics
  - use bitblt or stretchdraw to copy the first bitmap into the empty bitmap
  - create a new jpg-object, assign the seconf bitmap there
  - save it as new file or overwrite your existing one
- next file

meikl ;-)
0
 
LVL 12

Expert Comment

by:andrewjb
ID: 11879453
"Web picture creator" did it for me..
www.WebPictureCreator.com
0
 
LVL 2

Assisted Solution

by:Molando
Molando earned 200 total points
ID: 11882559
uses jpeg

procedure ResizePicture(path : string; width, height : integer);
var
 sr: TSearchRec;
 jpg : tjpegimage;
 bmp : tBitmap;
begin
 jpg := tJPEGImage.create;
 bmp := tBitmap.Create;
 bmp.width := width;
 bmp.Height := height;
 if FindFirst(path, faAnyFile, sr) = 0 then
    begin
      repeat
        if (pos('.JPG',uppercase(sr.name)) > 0) then  //ok we have found a jpeg
        begin
          jpg.LoadFromFile(sr.name);
          bmp.canvas.stretchdraw(bmp.canvas.cliprect,jpg);
          jpg.assign(bmp);
          jpg.SaveToFile(sr.name);
        end;
      until FindNext(sr) <> 0;
      FindClose(sr);
    end;
  jpg.free;
  bmp.free;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
resizePicture('c:\pic\*.*',800,600);
end;
0
 
LVL 25

Author Comment

by:Tomas Helgi Johannsson
ID: 11884930
I don't know how to split the Accepted answer but Molando should also get something as an assisted answer.
Thanks.

Regards,
  Tomas Helgi
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question