Jump to content
Sign in to follow this  

Resize Image

Recommended Posts


I spent some time with the search function today, downloading UDF's and trying different things out,.. but I can't find what I am looking for. It's probably because I don't know how to ask (the search function) or the solution is so simple that no one comments on it. So sorry in advance.

How can I resize an image? I'm not to worried about its format at this point because I think that PaulIA's Auto3Lib will do that for me. I am looking for something like this:

ImageResize ("Source Path", "Destination Path", Pixelwidth, PixelHeight)

If someone could show me what I am missing I would really appreciate it.

Edited by MagnumXL

Share this post

Link to post
Share on other sites

i am using nconvert as active x control which has the best resampler i could find in freeware



; light image converter

; using nconvert ACTIVEx now


; http://perso.orange.fr/pierre.g/xnview/de_downloadgfl.html


; all api functions can be taken from the help CHM file, which is extensive



; to register the active X control do this :

; copy GflAx.dll c:\winnt\system32

; regsvr32.exe GflAx.dll


; author nobbe, june 2007



#include <GUIConstants.au3>

$Form1 = GUICreate("nconvert sample", 633, 454, 193, 115, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPCHILDREN)

Dim $filemenu = GUICtrlCreateMenu("&File")

Dim $fileitem = GUICtrlCreateMenuitem("Open", $filemenu)

Dim $widthTh, $heightTh

$Height1 = 150

$Width1 = 150

$Obj1_ctrl = GUICtrlCreatePic("", 120, 32, $Width1, $Height1)


While 1

$nMsg = GUIGetMsg()

Switch $nMsg



Case $fileitem


$file = FileOpenDialog("Choose file...", @ScriptDir, "Picture Files (*.*)")

If @error <> 1 Then pic_Open($file)



Func pic_Open($file)


$newFile = resample($file, $Width1, $Height1)

$Obj1_ctrl = GUICtrlCreatePic(@ScriptDir & "\100_a.jpg", 120, 32, $widthTh, $heightTh)

; MsgBox(0,"",$file)

EndFunc ;==>pic_Open


; just resample the picture 1/4 of its orig size and save with diff qualities


Func resample($file, $Width1, $Height)

; the nconvert GFX api - if this fails you need to register the control first

$imgObject = ObjCreate("GflAx.GflAx")

If $imgObject <> 0 Then

$imgObject.LoadBitmap ($file);

$widthOrig = $imgObject.Width ()

$heightOrig = $imgObject.Height ()

;MsgBox(0, "", $widthOrig & "x" & $heightOrig)

$widthTh = Int($widthOrig / 4) ; 1/4 of original

$heightTh = Int($heightOrig / 4)

;var olecolor = red + (green * 256) + (blue * 65536);

; original RGB colors

$r = 255;

$g = 0;

$b = 255;

$olecolor = $r + ($g * 256) + ($b * 65536);

$imgObject.TextOut ("Test2 ", 50, 500, $olecolor) ; OLE_COLOR

; $imgObject.Sharpen(90)

; resize object

$imgObject.Resize ($widthTh, $heightTh)

$imgObject.SaveFormat = 1 ; jpeg

$imgObject.SaveJPEGQuality = 100 ; 100 % quality

$imgObject.SaveBitmap (@ScriptDir & "\100_a.jpg")

$imgObject.SaveJPEGQuality = 70 ; % quality

$imgObject.SaveBitmap (@ScriptDir & "\70_a.jpg")

$imgObject.SaveJPEGQuality = 40 ; % quality

$imgObject.SaveBitmap (@ScriptDir & "\40_a.jpg")

$imgObject.SaveJPEGQuality = 10 ; % quality

$imgObject.SaveBitmap (@ScriptDir & "\10_a.jpg")

EndIf ; imgobj ==0

EndFunc ;==>resample

Share this post

Link to post
Share on other sites

Thank you, Thank you, Thank you! I am leaving work now and will look into this first thing in the morning. Will report back then.

Share this post

Link to post
Share on other sites

Success! This was exactly what I was looking for! Thank you very much nobbe!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.