Jump to content
Sign in to follow this  
IAHIM

watermark an image with a png

Recommended Posts

IAHIM

Hi guys,

can someone give me a suggestion(maybe a sample code) on how to watermark an image with a specific transparent png that i already have?

the png is my logo and i want to add it to a set of images.

Just the basic help is needed - don't waste too much time on it.

Thank you kindly,

Mike

Share this post


Link to post
Share on other sites
mikell

Then here is a basic example  :)

Func _Watermark($sFile2, $sFile, $sLogo)
    Local $hImage1, $hImage2, $hGraphic
    
    _GDIPlus_Startup ()
    $hImage1 = _GDIPlus_ImageLoadFromFile ($sFile)   ; image
    $X1 = _GDIPlus_ImageGetWidth ($hImage1)
    $Y1 = _GDIPlus_ImageGetHeight ($hImage1)
    $hImage2 = _GDIPlus_ImageLoadFromFile ($sLogo)  ; logo
    $X2 = _GDIPlus_ImageGetWidth ($hImage2)
    $Y2 = _GDIPlus_ImageGetHeight ($hImage2)
    
    $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1)
    _GDIPlus_GraphicsDrawImage ($hGraphic, $hImage2, 0, $Y1-$Y2-30)  
    _GDIPlus_ImageSaveToFile ($hImage1, $sFile2)  ; image watermarked
    
    _GDIPlus_ImageDispose ($hImage1)
    _GDIPlus_ImageDispose ($hImage2)
    _GDIPlus_ShutDown ()
EndFunc   ;==>_Watermark

Share this post


Link to post
Share on other sites
IAHIM

Thanks mikell !!!!

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  

×