Simple Stegano Watermarker
Posted: Sat Jul 09, 2022 9:56 am
Simple STEGANO WATERMARKER Is a program that will insert a signature of your choice in the alpha layer of the last pixels of your photos.
The result is saved in PNG to keep the alpha layer.
You are free to improve it (encryption key etc...)
EnJoY
The result is saved in PNG to keep the alpha layer.
You are free to improve it (encryption key etc...)
EnJoY
Code: Select all
; =====================================================
;
; Simple STEGANO WATERMARKER
; by Ar-S // PB 6.00 x64
; https://ldvmultimedia.com
; 2022/07/09
; Free to use
;
; Only ASCII Chars avalaible
; ======================================================
Structure Car
min.c
maj.c
EndStructure
UsePNGImageDecoder()
UseJPEGImageDecoder()
UsePNGImageEncoder()
Declare.l pixel_3car(pixel)
Global NewList mot.car()
Global Fichier$
Global LONG
Global C
Global COUL.q
Procedure.l CatchPixel(pixel)
R=Red(pixel)
g=Green(pixel)
b=Blue(pixel)
a=Alpha(pixel)
If a - mot()\min > a -mot()\maj
a = mot()\maj
Else
a = mot()\min
EndIf
pixel=RGBA(R,G,B,a)
ProcedureReturn pixel
EndProcedure
Word$ = InputRequester("Watermark","Enter your signature","")
LONG = Len(Word$)
If LONG > 0
position = 1
For i = 1 To LONG
Lettre$ = Mid(Word$,position,1)
AddElement(mot())
mot()\min = Asc(LCase(Lettre$))
Mot()\maj = Asc(UCase(Lettre$))
position +1
Next
Else
MessageRequester("Error","You have to enter a word.. This program will end",#PB_MessageRequester_Error)
End
EndIf
IMAGE$ = ""
Filtre$ = "Image PNG/JPG/TIFF/TGA|*.tga;*.tiff;*.png;*.jpg"
Filtre = 0
Fichier$ = OpenFileRequester("Choose a picture", FichierParDefaut$, Filtre$, Filtre)
If Fichier$ = ""
End
EndIf
If LoadImage(0,Fichier$)
L = ImageWidth(0) - LONG
H = ImageHeight(0)-1
CreateImage(1, ImageWidth(0), ImageHeight(0), 32, $FFFFFF)
StartDrawing(ImageOutput(1))
DrawingMode(#PB_2DDrawing_AllChannels )
DrawAlphaImage(ImageID(0),0,0,255)
FreeImage(0)
POS = L
;-1st Pixel where we indicate the length of the watermark
LNGPIX = Point(0,0)
; We write the length
Plot(0,0,RGBA(Red(LNGPIX),Green(LNGPIX),Blue(LNGPIX),LONG))
ForEach mot()
COUL = Point(POS,H)
Debug "RGBA = " + Str(Red(COUL))+","+ Str(Green(COUL))+","+ Str(Blue(COUL))+","+ Str(Alpha(COUL))
Plot (POS,H, CatchPixel(COUL))
POS+1
Next
StopDrawing()
DS$ = GetPathPart(Fichier$)
FS$ = GetFilePart(Fichier$,#PB_FileSystem_NoExtension)
Debug DS$+FS$+".png"
SaveImage(1,DS$+FS$+"_signed.png",#PB_ImagePlugin_PNG,0,32 )
FreeImage(1)
;-// CHECKING RESULT //////////////////////////////////////
If LoadImage(0,DS$+FS$+"_signed.png")
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AlphaChannel)
LONG = Alpha(Point(0,0))
L = ImageWidth(0) - LONG
H = ImageHeight(0)-1
POS = L
For i = 1 To LONG
Debug Chr(Alpha(Point(POS,H)))
POS+1
Next
StopDrawing()
EndIf
EndIf