When you say size, I am not sure if you mean file size or pixels. The solution would vary accordingly.
If you have to do just one image, I would do something like what I did in this PerfectScript macro for WordPerfect: http://www.wpuniverse.com/vb/showthr...threadid=30690
So you won't have to register to see the code at the site above, it is shown next. You can look at IRFanView's help for Command Line Switches for details on what you can do. The PerfectScript code is a bit similar to VBA so it should not be difficult to see what I did.
//PasteOneGraphic.wcm by Kenneth Hobson, February 27, 2010
//http://tiporama.com/tools/pixels_inches.html
dpi=94 //Change to fit your screen. Images wider than wPage should fit to magins.
//imageFile="c:\myfiles\pics\onelanebridge.jpg" //Used for testing.
//Exit if macro was not passed an argument, graphic file's drive:\path\filename.ext.
If (MacroArgs[0]=0)
MessageBox(;"Macro Ending";"No image drive:\path\filename.ext was passed.";IconStop!)
Go(EndNow)
EndIf
imageFile=MacroArgs[1]
//Exit if imageFile does not exist.
If (Not(DoesFileExist(imageFile)))
MessageBox(;"Image Does Not Exist";imageFile;IconStop!)
Go(EndNow)
EndIf
//End if IrfanView is not installed.
irfanview="C:\Program Files\IrfanView\i_view32.exe"
irfanview="C:\Program Files (x86)\IrfanView\i_view32.exe"
If (Not(DoesFileExist(irfanview)))
MessageBox(;"IrfanView Not Found";irfanview;IconStop!)
Go(EndNow)
EndIf
irfanviewq=""""+irfanview+""""+" "
//Create a temporary TXT filename.
tempdir=EnvVariableGet("temp")+"\"
If (Not(DoesDirectoryExist(tempdir)))
tempdir=EnvVariableGet("tmp")+"\"
EndIf
If (Not(DoesDirectoryExist(tempdir)))
tempdir="c:\"
EndIf
tempFile=tempdir+"IrfanView.txt"
//Delete tempFile if it exists.
If (DoesFileExist(tempFile))
DeleteFile(tempFile;NoPrompts!)
EndIf
//Create a file to save resized image or image
CopyGraphic=tempdir+"PasteOneGraphic.jpg"
//Delete CopyGraphic if it exists
If (DoesFileExist(CopyGraphic))
DeleteFile(CopyGraphic;NoPrompts!)
EndIf
//Create the tempFile of image information in IrfanView.
str=q(irfanview)+" "+q(imageFile)+" /info="+q(tempFile)+" /killmesoftly"
AppExecute(str)
//Loop until tempFile is created.
Repeat
Wait(1)
Until(DoesFileExist(tempFile))
//Create an array with each line from tempFile.
imageInfo[]=FileToArray(tempFile)
//Find out the available wPage and hPage less the margins on the current page.
wPage=ConvertType(?PaperWidth-?MarginRight-?MarginLeft;Number!)/1200
hPage=ConvertType(?PaperLength-?MarginBottom-?MarginTop;Number!)/1200
//Split imageInfo[] to get the parts needed for resizing computations.
dimLine[]=StrParseList(imageInfo[6];" ")
wPixel=dimLine[4]
wInches=wPixel/dpi
hPixel=dimLine[6]
hInches=hPixel/dpi
ratio=ConvertType(wPixel;Number!)/ConvertType(hPixel;Number!)
If (ratio>=1)
ls="long"
Else ls="short"
EndIf
resize=" /resize_"+ls+"="
If (wInches>wPage)
wInches=wPage
resize=resize+(wInches*dpi)+" /aspectratio /resample"
else resize=""
EndIf
//Resize if needed and copy the graphic to the clipboard.
str=q(irfanview)+" "+q(imageFile)+resize+" /clipcopy /convert="+CopyGraphic+" /transpcolor=(256,256,256) /killmesoftly"
AppExecute(str)
//Paste after CopyGraphic is created.
Repeat
Wait(1)
Until(DoesFileExist(CopyGraphic))
EditPaste()
//FileOpen(tempFile) //Check image info.
Go(EndNow)
Function q(str)
If (StrPos(str; """")>0)
Return(str)
EndIf
qq=""""
Return(qq+str+qq)
EndFunc
Names[]=FileToArray("c:\myfiles\wp\Names.txt")
Function FileToArray(vFile) //Read File into array and return array
hFile=OpenFile (vFile; Read!; Compatibility!; AnsiText!)
If (hFile=OpenFile.Error!)
MessageBox (; "Open File Problem"; "Error processing password '^0' file!";
IconStop!+HasParameters!; vFile)
Quit
EndIf
Count=0
Wait(1) //Needed for fast computers.
FilePosition(hFile; 0; FromBeginning!)
While (not FileIsEOF (hFile))
Count = Count+1
FileRead (hFile; x)
EndWhile
FilePosition(hFile; 0; FromBeginning!)
Declare TempArray[Count]
x=0
While (not FileIsEOF (hFile))
x=x+1
FileRead (hFile; TempArray[x])
EndWhile
CloseFile (hFile)
Return(TempArray[])
EndFunc
EndNow: