Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8089019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:16:19+00:00 2026-06-05T19:16:19+00:00

The images iam loading are slightly different sizes. how can i get the smallest

  • 0

The images iam loading are slightly different sizes. how can i get the smallest size and re-size them all to that size?

The code below is the loading of the images -> converting to bmp -> adding to imagelist

after about 3 images it gives error invalid image size. due to image size too big for the size i gave imagelist at start.

procedure TForm1.LoadImages(const Dir: string);
var
  z,i: Integer;
  CurFileName: string;
  JpgIn: TJPEGImage;
  BmpOut: TBitmap;
begin
  i := 0;
  z := 1;
  while True do
  begin
    CurFileName := Format('%s%d.jpg',
                          [IncludeTrailingPathDelimiter(Dir), i]);
    if not FileExists(CurFileName) then
      Break;
    JpgIn := TJPEGImage.Create;
    try
      JpgIn.LoadFromFile(CurFileName);
      if z = 1 then
       begin
        ImageList1.SetSize(jpgin.width, jpgin.Height);
        z := 0;
       end;
      BmpOut := TBitmap.Create;
      try
         BmpOut.Assign(JpgIn);
         ImageList1.Add(BmpOut, nil);
      finally
        BmpOut.Free;
      end;
    finally
      JpgIn.Free;
    end;
    Inc(i);
  end;
  if ImageList1.Count > 0 then
  begin
    BmpOut := TBitmap.Create;
    try
      ImageList1.GetBitmap(1, BmpOut);
      zimage1.Bitmap.Assign(bmpout);
      zimage1.Repaint;
    finally
      BmpOut.Free;
    end;
  end;
end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:16:21+00:00Added an answer on June 5, 2026 at 7:16 pm

    Once you start putting images into the TImageList, you cannot resize it, and all images must be the same size. So you will have to pre-load all of the images ahead of time so you can then determine the smallest size available, THEN crop/stretch any larger images to the smaller size, THEN you can load the final images into the TImageList.

    Have your loop store all of the TJPEGImage into a TList or TObjectList and not free them right away, then you can loop through that list calculating the smallest size, then loop through the list again resizing the images as needed, then loop through the list again adding the images to the TImageList, and then finally loop through the list freeing the images.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am loading in images with varying sizes and putting them in UIScrollViews, all
I am loading images of different size and then images are scaled and border
I am using following code for loading images from server using following code.When i
Iam desghning glitter text generating website ..where users can select glitters[images] to put it
I am loading an image using a Loader. Once loaded, I can get the
I am loading images in background . using this code -(void)backgroundImageLoading { if(isGroupOrFriend) {
I am loading a bunch of images using knockoutjs. I get a json object
I am loading images of size 1800x1300 in UIImage.(getting the images from server..)then i
I am loading the images of size 450KB in UIImage view and then adding
I have a UIScrollView that I am loading some images in. Sometimes I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.