Jump to content

Place text in image and save

Recommended Posts

Hello again guys. Hope you're all having a nice weekend.

Ok, so... i have a question i hope you can help me with.

I have a program (almost finished) to make reports for my company, and at the end of the report, the program places an image of a digitalized signature of the guy that makes the report, but.... i'm trying to add some security to it, so our clients, don't just steal that digital signature and place it in another report.

So, i thought about adding the date to that picture (signature), and save the picture after so the picture and the date in it are all the same and not distinct objects. Is there a way to do that?

Ofcourse this is just my idea in how to add extra security to the signatures, but i'm open to suggestions :oops:

Link to post
Share on other sites

May be something like this

#include <GDIPlus.au3>

_AddTextToPic ( @DesktopDir & 'Image.jpg', @MyDocumentsDir & 'Image2.jpg', "Signature", 20, 450 )
_DisplayPic ( @MyDocumentsDir & 'Image2.jpg' )

Func _AddTextToPic ( $_ImagePath, $_Outputpath, $sString, $_X=0, $_Y=0 )
    Local $hBitmap, $hImage, $hGraphic, $hFamily, $hFont, $tLayout, $hFormat, $aInfo, $hBrush1, $hBrush2, $iWidth, $iHeight, $hPen
    ; Initialize GDI+ library
    _GDIPlus_StartUp ( )
    ; Load image and emboss text
    $hImage   = _GDIPlus_ImageLoadFromFile ( $_ImagePath )
    $hGraphic = _GDIPlus_ImageGetGraphicsContext ( $hImage )
    $hFamily  = _GDIPlus_FontFamilyCreate ( "Arial" )
    $hFont    = _GDIPlus_FontCreate ( $hFamily, 38, 1 )
    $hFormat  = _GDIPlus_StringFormatCreate ( 0x4000 )
    $hBrush2  = _GDIPlus_BrushCreateSolid ( 0xff000000 )
    $hPen     = _GDIPlus_PenCreate ( 0xC4000000, 1 )
    ; Set Text Pos
    $tLayout  = _GDIPlus_RectFCreate ( $_X, $_Y )
    $aInfo    = _GDIPlus_GraphicsMeasureString ( $hGraphic, $sString, $hFont, $tLayout, $hFormat )
    _GDIPlus_GraphicsDrawStringEx ( $hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush2 )
    ; Save image
    _GDIPlus_ImageSaveToFile ( $hImage, $_Outputpath )
    ; Free resources
    _GDIPlus_PenDispose ( $hPen )
    _GDIPlus_BrushDispose ( $hBrush1 )
    _GDIPlus_BrushDispose ( $hBrush2 )
    _GDIPlus_StringFormatDispose ( $hFormat )
    _GDIPlus_FontDispose ( $hFont )
    _GDIPlus_FontFamilyDispose ( $hFamily )
    _GDIPlus_GraphicsDispose ( $hGraphic )
    _GDIPlus_ImageDispose ( $hImage )
    _GDIPlus_ShutDown ( )
EndFunc ;==> _AddTextToPic ( )

Func _DisplayPic ( $_ImagePath )
    Run ( 'rundll32 shimgvw.dll,ImageView_Fullscreen ' & $_ImagePath )
EndFunc ;==> _DisplayPic ( )

AutoIt X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to post
Share on other sites

I wrote some time ago a function to write a text to an image: Write Text on Bitmap()

Maybe it is useful for you.

Link points to the German Autoit site.



Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to post
Share on other sites

The error is telling you that you didn't copy _DisplayPic from wakillon's example.

UDF List:

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...