Solved

Some Image questions.

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

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now