i have different sige of photo files which was scanned through a scaner and save as *.jpg file , now i want to use all this files in a form made in vb6 where i want to link all these files trough data base so that i can see each photos one by one . but these file has different width and hight but in my form i have make a fix space , so i want to make all these photo files of same width and hight to fit and defined space . but i want this through some program , because this photos are approx. 40000. so manually is not possible. pls help me.

Dani AI

Generated

Quick practical plan for (and a note on the replies from , and ): preprocess the 40,000 scans into a uniform set of files before linking them into your VB6 form. Decide which strategy you need: scale-to-fit (no cropping), scale-and-pad (keeps whole image, centers it on a fixed canvas), or scale-and-crop (fills the frame but may cut edges). For scanned photos, scale-and-pad is usually safest. Back up originals, test on a small batch, then run the full job.

Keep the image’s aspect ratio. Compute sizes like this:

scale = Min(targetW / origW, targetH / origH)
newW  = Round(origW * scale)
newH  = Round(origH * scale)

Place the scaled image centered on a canvas of targetW x targetH and fill the background with the form’s background color.

Fast, reliable options:

  • Use a dedicated batch tool (comfortable for very large sets). Example with ImageMagick (test first):
    mkdir resized
    mogrify -path resized -resize 300x200 -background white -gravity center -extent 300x200 -quality 95 *.jpg

    Or, per-file with auto-orient:

    for f in *.jpg; do
    convert "$f" -auto-orient -resize 300x200 -background white -gravity center -extent 300x200 -quality 95 "resized/$f"
    done

    Set JPEG quality high (e.g. 90–95) to avoid ugly artifacts and preserve metadata/EXIF where needed.

If you want an in-app converter (inside VB6) do it without showing each image: use a proper image library (GDI+ or WIA), load files, compute scaled size, render to a target bitmap with high-quality interpolation, then save with JPEG encoder parameters. Process files in batches, keep originals, and store only the resized-paths in your database for fast form loading.

Recommended Answers

All 4 Replies

Yes, But it's a lot more detailed and complex than you might think. Basically, I've devised a way using the API (StretchBlt) That shows how you can copy an image from a picture box, to another picturebox, changing size from one to the other. A Few things to note, is that the quality diminishes during this process (quality of the picture) AND the picture must be visible in order to copy from it. This project loads an image into form2, and when you click the button, makes form2 visible (makes the picture visible), and then copies it to the picturebox on form1, and then hides form2.

As you can see, this would be intensive on the processor, and probably take up quite a bit of RAM. I'm still devising a way to use objects or API Calls to specific graphic programs that would allow for better picture quality and faster processing, but for now, this is how to use the stretchblt API.

thank u Comatose
it is nice solution , but i want in my project that first i will make all the available jpg files of same size than i will use these files in my project form directly by applying simply a path of that file , so i need that type of converter which will make all available jpg file to same size

i have different sige of photo files which was scanned through a scaner and save as *.jpg file , now i want to use all this files in a form made in vb6 where i want to link all these files trough data base so that i can see each photos one by one . but these file has different width and hight but in my form i have make a fix space , so i want to make all these photo files of same width and hight to fit and defined space . but i want this through some program , because this photos are approx. 40000. so manually is not possible. pls help me.

Two thoughts.

- Change the size in a photo editor.

- Make a blank (white or black) space larger than the photo, then do the equivalent of pasting the photo into it.

Two thoughts.

- Change the size in a photo editor.

- Make a blank (white or black) space larger than the photo, then do the equivalent of pasting the photo into it.

There was a program called WINJPEG (shareware) where you could batch reduce. Set the size you wanted the photos and walk away. MAINTAIN Aspect RATIOS!! for sharper output images.

I would make a blank square. where the photos could fit, landscape or portrait. Paste all into blank square , then batch resize.

Watch for compression change. some will compress original too much and you have a lot of 'jaggies' or unusable image. (Keep at 100% for your existing quality)

I had to place over 3000 images of albums in The Complete Motown and it was a learning experience. Though I only had to work with smaller sized images.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.