JPGs mit Wasserzeichen versehen und auf 800x600px schrumpfen

  • Hallo!
    Ich bin dabei, für meine Klasse die Fotos vom letzten Ausflug hochzuladen. Dazu sollen sie zu erst auf 800x600px verkleinert werden und dann unten rechts mit meinem Wasserzeichen (Weißer Schriftzug "Foto by tobi_girst") versehen werden. Ist das in Autoit möglich und wenn ja, wie? Am besten wäre es, wenn es alle Daeien in einem Ordner auswählen würde. (Wenn das so klingt als wär das ein "Macht ihr mal bitte"-Post, so wars nicht gemeint!)

    MfG. tobi_girst

    MfG. tobi_girst

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »tobi_girst« (Morgen, 25:63)

  • Das musst du wohl mit GDIPlus machen

    kleine Anregung für einen SChriftzug der auf ein Bild kommen soll: (ganz schnell zusammen geklatscht, habe gerade nicht viel zeit)

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    $hImage2=_GDIPlus_BitmapCreateFromFile(@desktopdir & "\bild.jpg")
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage2)
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)

    [/autoit] [autoit][/autoit] [autoit]

    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 14)
    $hLayout = _GDIPlus_RectFCreate(600, 400, 600, 800)
    $hStringFormat = _GDIPlus_StringFormatCreate()

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Foto by tobi_girst", $hFont, $hLayout, $hStringFormat, $hBrush)

    _GDIPlus_ImageSaveToFile($hImage2, @desktopdir & "\beispiel.jpg")

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Brushdispose($hBrush)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_StringFormatDispose($hStringFormat)

    _WinAPI_DeleteObject($hImage2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()

    [/autoit]
  • Oje, mit GDI+ kenne ich mich gar nicht aus! ?(?(
    Vielleicht soll ich doch lieber alle 140 Pics einzeln und per Hand machen...oder es wäre jemand so nett, mir ein Script zu posten :D (was aber warscheinlich keiner tun wird)

    MfG. tobi_girst

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »tobi_girst« (Morgen, 25:63)

  • Es lohnt sich wirklich sich mit GDIplus auseinader zu setzten!

    So, mein Beispiel sollte jetzt gehen:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    _Wasserzeichen(@desktopdir & "\vorschau.jpg",@desktopdir & "\beispiel.jpg","Foto by tobi_girst")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    func _Wasserzeichen($input,$ouput,$text)
    _GDIPlus_Startup() ;<=======Startup
    $hImage2=_GDIPlus_BitmapCreateFromFile($input) ;<======Das Bild wird geöffnet
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage2)
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000) ;<======Farbe der Schrift

    [/autoit] [autoit][/autoit] [autoit]

    $hFamily = _GDIPlus_FontFamilyCreate("Arial") ;<======Schriftart
    $hFont = _GDIPlus_FontCreate($hFamily, 16) ;<======Schriftgröße
    $hLayout = _GDIPlus_RectFCreate(650, 560, 800, 600) ;<======position der Schrift
    $hStringFormat = _GDIPlus_StringFormatCreate()

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawStringEx($hGraphic, $text, $hFont, $hLayout, $hStringFormat, $hBrush) ;<======Die schrift wird drauf gemalt

    _GDIPlus_ImageSaveToFile($hImage2,$ouput); <======Das neue Bild wird gespeichert

    [/autoit] [autoit][/autoit] [autoit]

    ;<======Es wird aufgeräumt ;)
    _GDIPlus_Brushdispose($hBrush)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_StringFormatDispose($hStringFormat)

    _WinAPI_DeleteObject($hImage2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown() ;<======GDIplus wird beendet
    endfunc

    [/autoit]
  • Hey, dake! Echt ein toller service da bei der besten AutoIt-Community dies gibt! :D:thumbup::thumbup:
    Wegen dem Verkleinern muss ich jetzt aber auch noch mal lästig sein:Das geht schätze ich auch nur über GDI+, oder?

    MfG. tobi_girst

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »tobi_girst« (Morgen, 25:63)

  • nutz doch einfach 1 von 42.341.144.663.521,5 Freeware Tools -> z.B. IrfanView - Kostenlos, schnell und perfekte Resultate - und dazu "kinderleicht" zu bedienen :rock:

    Zitat

    Laughing Man

    "I thought, what I'd do was, I'd pretend I was one of those deaf-mutes"

  • Nutz das nächste mal zuerst google -.-

    Hier, das ist ein Script zum verkleinern von autoitscript.com

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <WinAPI.au3>

    [/autoit] [autoit][/autoit] [autoit]

    _ImageResize(@desktopdir & "\beispiel.jpg", @DesktopDir& "\RIP.jpg", 600, 400)

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# =========================================================================================
    ; Name...........: _ImageResize
    ; Description....: Resize an image and optionally convert it to the format you want.
    ; Syntax.........: _ImageResize($sInImage, $sOutImage, $iW, $iH)
    ; Parameters ....: $sInImage - Full path to the image to resize / convert.
    ; In types: *.bmp, *.gif, *.ico, *.jpg, *.jpeg, *.png, *.tif, *.tiff
    ; $sOutImage - Full path where to save the resized / converted image.
    ; Out types: *.bmp, *.gif, *.jpg, *.jpeg, *.png, *.tif, *.tiff
    ; $iW - Width to resize image to.
    ; $iH - Height to resize image to.
    ; Return values .: Success - Return 1 and @error 0
    ; Failure - Return 0 and @error 1~5
    ; @error 1 = In File does not exist
    ; @error 2 = In File format not supported
    ; @error 3 = Out File path does not exist
    ; @error 4 = Out file format not supported
    ; @error 5 = Resize Width or Height not an integer
    ; Author ........: smashly
    ; ====================================================================================================

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ImageResize($sInImage, $sOutImage, $iW, $iH)
    Local $sOP, $sOF, $sInExt, $Ext, $hBitmap, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0
    Local $sType = "BMP|GIF|ICO|JPG|JPEG|PNG|TIF|TIFF"

    If Not FileExists($sInImage) Then Return SetError(1, 0, 0)
    $sInExt = StringUpper(StringTrimLeft($sInImage, StringInStr($sInImage, ".", 0, -1)))
    If Not StringRegExp($sInExt, "\A(" & $sType & ")\z", 0) Then Return SetError(2, 0, 0)

    ;OutFile path, to use later on.
    $sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))
    If Not FileExists($sOP) Then Return SetError(3, 0, 0)

    ;OutFile name, to use later on.
    $sOF = StringTrimLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))

    [/autoit] [autoit][/autoit] [autoit]

    ;OutFile extension , to use for the encoder later on.
    $Ext = StringUpper(StringTrimLeft($sOutImage, StringInStr($sOutImage, ".", 0, -1)))
    If Not StringRegExp($Ext, "\A(" & $sType & ")\z", 0) Or $Ext = "ICO" Then Return SetError(4, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    If Not IsInt($iW) And Not IsInt($iH) Then Return SetError(5, 0, 0)


    ;Start GDIPlus
    _GDIPlus_Startup()

    ;Load the image you want to resize.
    $hImage2 = _GDIPlus_ImageLoadFromFile($sInImage)
    $iOriginalHeight = _GDIPlus_ImageGetHeight($hImage2)
    $iOriginalWidth = _GDIPlus_ImageGetWidth($hImage2)

    ;create a blank DIBSection
    If $iOriginalHeight > $iOriginalWidth then
    $hBitmap = _WinAPI_CreateCompatibleBitmapSection($iW,$iH)
    Else
    $hBitmap = _WinAPI_CreateCompatibleBitmapSection($iH,$iW)
    EndIf


    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ;Get the graphic context of the blank bitmap
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)

    [/autoit] [autoit][/autoit] [autoit]

    ;Draw the loaded image onto the blank bitmap at the new size
    If $iOriginalHeight > $iOriginalWidth then
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH)
    Else
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iH, $iW)

    EndIf

    ;see if the image needs to be saved rotated
    $Rotate = 0
    If $iW < $iH and $iOriginalHeight < $iOriginalWidth then $Rotate = 1
    If $iW > $iH and $iOriginalHeight > $iOriginalWidth then $Rotate = 1

    [/autoit] [autoit][/autoit] [autoit]

    ;Get the encoder of to save the resized image in the format you want.
    $CLSID = _GDIPlus_EncodersGetCLSID($Ext)

    [/autoit] [autoit][/autoit] [autoit]

    ;Save the new resized image.
    If $Rotate = 1 then
    _GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage & ".tmp", $CLSID);save the image temporarily
    $hImage = _GDIPlus_ImageLoadFromFile($sOutImage & ".tmp");reload the tmp image
    $tData = DllStructCreate("int Data")
    DllStructSetData($tData, "Data", $GDIP_EVTTRANSFORMROTATE90)
    $tParams = _GDIPlus_ParamInit (1)
    _GDIPlus_ParamAdd ($tParams, $GDIP_EPGTRANSFORMATION, 1, $GDIP_EPTLONG, DllStructGetPtr($tData, "Data"))
    _GDIPlus_ImageSaveToFileEx ($hImage, $sOutImage, $CLSID, DllStructGetPtr($tParams));resave with the rotate
    _GDIPlus_ImageDispose($hImage)

    [/autoit] [autoit][/autoit] [autoit]

    Else
    ;Msgbox(0,"Save",_GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;Clean up and shutdown GDIPlus.
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _WinAPI_DeleteObject($hBitmap)

    While FileExists($sOutImage & ".tmp");delete the .tmp
    FileDelete($sOutImage & ".tmp")
    Wend

    _GDIPlus_Shutdown()
    Return SetError(0, 0, 1)
    EndFunc ;==>_ImageResize

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _WinAPI_CreateCompatibleBitmapSection($iWidth,$iHeight,$iBitCount=24)

    $tBMI = DllStructCreate($tagBITMAPINFO)
    DllStructSetData($tBMI, "Size", DllStructGetSize($tBMI) - 4)
    DllStructSetData($tBMI, "Width", $iWidth)
    DllStructSetData($tBMI, "Height", $iHeight)
    DllStructSetData($tBMI, "Planes", 1)
    DllStructSetData($tBMI, "BitCount", $iBitCount)

    [/autoit] [autoit][/autoit] [autoit]

    $aDIB = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', _
    'ptr', 0, _
    'ptr', DllStructGetPtr($tBMI), _
    'uint', 1, _
    'ptr*', 0, _
    'ptr', 0, _
    'uint', 0)
    Return $aDib[0]

    EndFunc

    [/autoit]
  • Irfanview
    Datei-->Batchkonvertierung
    dort bei Optionen die Spezialoptionen auswählen, Text einfügen und dort bei Optionen den Text bearbeiten

    ...man muss auch mit Autoit nicht das Rad neu erfinden ;)

    ciao
    Andy

  • Zitat von Oger-Lord

    Nutz das nächste mal zuerst google -.-


    Werd ich machen, sry!

    Andy: Cool, das IrfanView das kann, wusste ich nicht!
    Jedenfalls Thx @ all!

    MfG. tobi_girst

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »tobi_girst« (Morgen, 25:63)

  • Tausend Dank Oger-Lord! ich konnte dein script soweit umbauen das es für mich Nützlich wurde!

    Und zwar brauch ich nicht EIN Wasserzeichen, sondern will die Artikel Nummer in jedem Bild unten drin haben. Und die variiert natürlich jedes mal.

    Das sieht jetzt etwa so aus: Da brauch ich nur noch das Bild auf die compiled .exe zu ziehen und schon kann ich die Nummer eingeben.

    Spoiler anzeigen
    [autoit]

    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Outfile=..\..\..\Users\HD\Desktop\Test.exe
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include <GDIPlus.au3>
    $ArtNr = InputBox ("Artikel Nummer", "Bitte eingeben"&@CRLF&@CRLF&"Artikel Nummer", "1001001", "", 350, 150)
    If @error then Exit
    $eingabe = "Art. "&$ArtNr
    ToolTip ("Working", 0, 0)
    _Wasserzeichen($CmdLine[1],@desktopdir & "\"&$ArtNr&".jpg", $eingabe)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    func _Wasserzeichen($input,$ouput,$text)
    _GDIPlus_Startup() ;<=======Startup
    $hImage2=_GDIPlus_BitmapCreateFromFile($input) ;<======Das Bild wird geöffnet
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage2)
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000) ;<======Farbe der Schrift

    [/autoit] [autoit][/autoit] [autoit]

    $hFamily = _GDIPlus_FontFamilyCreate("Arial") ;<======Schriftart
    $hFont = _GDIPlus_FontCreate($hFamily, 100) ;<======Schriftgröße
    $hLayout = _GDIPlus_RectFCreate(3740, 3345, 1200, 200) ;<======position der Schrift
    $hStringFormat = _GDIPlus_StringFormatCreate()

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawStringEx($hGraphic, $text, $hFont, $hLayout, $hStringFormat, $hBrush) ;<======Die schrift wird drauf gemalt

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_ImageSaveToFile($hImage2,$ouput); <======Das neue Bild wird gespeichert

    [/autoit] [autoit][/autoit] [autoit]

    ;<======Es wird aufgeräumt ;)
    _GDIPlus_Brushdispose($hBrush)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_StringFormatDispose($hStringFormat)

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_DeleteObject($hImage2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown() ;<======GDIplus wird beendet
    ToolTip("")
    endfunc

    [/autoit]