resizing an image (1 Viewer)

John Sh

Active member
Local time
Tomorrow, 06:26
Joined
Feb 8, 2021
Messages
637
I have a situation where I am adding bulk .jpg images, 2 or 3 hundred at a time, to a folder for display in access in an image control.
If the images are too large, 3 or 4mb then they take too long to load
Using the software below to resize an image is reducing the mb size of the image even when the original is of similar pixel size to the output image.
E.g. an image of 998 x1200 and 1.5mb is resized to 998 x 1200 and 99kb. The resolution obviously suffers.
An image of 2997 x 3531 and 12.1mb is also reduced to 998 x 1200 and 99kb.
That large image reduced in external software is reduced to 998 x1200 1.7mb
Is there a better way to resize images on the fly.

Code:
Public Sub reSize(sInit As String)
    Dim oWIA    As Object
    Dim oIP     As Object
    Dim nHeight As Integer
    Dim nWidth  As Integer
    Dim sResize As String
    nHeight = 1200
    nWidth = 1800
    Set oWIA = CreateObject("WIA.imagefile")
    oWIA.LoadFile sInit
    Set oIP = CreateObject("WIA.imageprocess")
    oIP.Filters.Add oIP.FilterInfos("Scale").FilterID
    oIP.Filters(1).Properties("MaximumHeight") = nHeight
    oIP.Filters(1).Properties("MaximumWidth") = nWidth
    Set oWIA = oIP.Apply(oWIA)
    Kill sInit
    oWIA.SaveFile sInit
    Set oWIA = Nothing
End Sub
 
Define "better".
I'm assuming your image control is set to 1200 x 1800 pixels, so resizing to that size makes sense to me. The image quality is secondary.
Certainly you could offer a button which would open the original image in the default viewer on the machine. That way users get the best of both worlds.
 
Define "better".
I'm assuming your image control is set to 1200 x 1800 pixels, so resizing to that size makes sense to me. The image quality is secondary.
Certainly you could offer a button which would open the original image in the default viewer on the machine. That way users get the best of both worlds.
The image size is actually set to 1800 x 1200, width x height. They are all in landscape orientation.
"Better" would be if the image mb size was more in keeping with the external software size of 1.7mb instead of 99kb.
As for "That way users get the best of both worlds.", the difference in storing thousands of 12mb images to 1.7mb images is a lot of storage space.
 
you can also try ImageMagick using shell command to manipulate the image size.
see for yourself which one is faster, WIA or ImageMagick.
 
you can also try ImageMagick using shell command to manipulate the image size.
see for yourself which one is faster, WIA or ImageMagick.
The biggest problem is it would have to be installed on each user's computer, so it looks like WIA is the go.
Thank you.
 
Is there a better way to resize images on the fly.
The GDI+ API(*) gives you more control over image transformation. It is also quite a bit more complex to use than the fairly simple WIA code. - It's for you to decided which is better. ;-)


*=I linked to the "GDI+ Flat API" and the text tells you not to use the "Flat API", but with VBA you must use the "Flat API" unless you want the addition challenges of using the C++ classes directly.
 
The image size is actually set to 1800 x 1200, width x height. They are all in landscape orientation.
"Better" would be if the image mb size was more in keeping with the external software size of 1.7mb instead of 99kb.
As for "That way users get the best of both worlds.", the difference in storing thousands of 12mb images to 1.7mb images is a lot of storage space.
10,000 images at 12 mb each would take up 120 GB space. It is not possible today to buy a hard drive that small.
 

Users who are viewing this thread

Back
Top Bottom