Solved

Some Image questions.

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

815 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

11 Experts available now in Live!

Get 1:1 Help Now