Hallo zusammen,
hat jemand von euch vieleicht schon eine Funktion erstellt um die Bildgröße zu ändern (nicht das Bild zu beschneiden)?
Also nicht so was (mal auf die schnelle):
[autoit]#include <GDIPlus.au3>
[/autoit][autoit][/autoit][autoit]$path = FileSelectFolder( "Ordner auswählen wo das Bildformat geändert werden muß?", "C:\Users\alex\", 1)
$path1 = DirCreate($path & "\1024x768")
Search($path, "jpg")
Func Search($current, $ext)
Local $search = FileFindFirstFile($current & "\*.*")
While 1
Local $file = FileFindNextFile($search)
If @error Or StringLen($file) < 1 Then ExitLoop
If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then
If StringRight($current & "\" & $file, StringLen($ext)) = $ext Then
_GDIPlus_Startup()
$hBitmap = _GDIPlus_BitmapCreateFromFile($current & "\" & $file)
$iX = _GDIPlus_ImageGetWidth($hBitmap)
$iY = _GDIPlus_ImageGetHeight($hBitmap)
;MsgBox(0, "Grösse: ", "Breite: " & $iX & @LF & "Höhe: " & $iY)
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_Shutdown()
Dim $iX1, $iY1
If $iX < $iY Then
$iX = $iY1
$iY1 = 1024
$iY = $iX1
$iX1 = 768
Else
$iX = $iX1
$iX1 = 1024
$iY = $iY1
$iY1 = 768
EndIf
;MsgBox(0, "Grösse: ", "Breite: " & $iX1 & @LF & "Höhe: " & $iY1)
_ImageResize($current & "\" & $file, $current & "\1024x768\" & $file, $iX1, $iY1)
EndIf
EndIf
If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then
Search($current & "\" & $file, $ext)
EndIf
WEnd
FileClose($search)
EndFunc
Func _ImageResize($sInImage, $sOutImage, $iW, $iH)
Local $hWnd, $hDC, $hBMP, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0
Local $sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))
Local $sOF = StringMid($sOutImage, StringInStr($sOutImage, "\", 0, -1) + 1)
Local $Ext = StringUpper(StringMid($sOutImage, StringInStr($sOutImage, ".", 0, -1) + 1))
$hWnd = _WinAPI_GetDesktopWindow()
$hDC = _WinAPI_GetDC($hWnd)
$hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH)
_WinAPI_ReleaseDC($hWnd, $hDC)
_GDIPlus_Startup()
$hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBMP)
$hImage2 = _GDIPlus_ImageLoadFromFile($sInImage)
$hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1)
_GDIPLus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iW)
$CLSID = _GDIPlus_EncodersGetCLSID($Ext)
Do
$i += 1
Until (Not FileExists($sOP & $i & "_" & $sOF))
$sOutImage = $sOP & $i & "_" & $sOF
_GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID)
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_ImageDispose($hImage2)
_GDIPlus_GraphicsDispose ($hGraphic)
_WinAPI_DeleteObject($hBMP)
_GDIPlus_Shutdown()
EndFunc
z.B.: von 2304x1728 auf 1024x768.
Falls das schon jemand gemacht hat wäre ich sehr dankbar.
p.s. habe schon lange nichts mehr in AutoIt gemacht
Danke vorab.
pastl