Solved

Some Image questions.

Posted on 2004-08-24
5
150 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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to update exe applicatio from internet ? 6 92
Graphics32 under Delphi 10.1 Berlin 2 123
Browsing a TTreeView in Delphi 5 31
Delphi Firemonkey send email on Android 1 38
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…

713 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