Sign in to follow this  
Followers 0
iamsandeep

How to add details in a picture(gif)

8 posts in this topic

Hi guys,

Need some help here,I'm doing a screen capture and saving the image with .gif extension, then i'm taking some information from the user about the image[will build this function as soon as my issue resolves].now i need to attach the information to the image properties so that the image itself can hold information about it.

not able to get the idea how to do it.

Please help me out guys ..

Thnx a mil in advance coz i have faith in u ppl.

test_screenshot_BKUP.au3

Share this post


Link to post
Share on other sites



Hi guys,

Need some help here,I'm doing a screen capture and saving the image with .gif extension, then i'm taking some information from the user about the image[will build this function as soon as my issue resolves].now i need to attach the information to the image properties so that the image itself can hold information about it.

not able to get the idea how to do it.

Please help me out guys ..

Thnx a mil in advance coz i have faith in u ppl.

Can you tell us the goal of this whole project? What purpose will the screenshots have? What information do you want to store in the gif?

Share this post


Link to post
Share on other sites

Sure,

I will be glad to share the objective of the project.I am a test engineer so my job involves logging the bugs in a product,and to do that i have to take huge number of screenshots and a really sad part of my work is i need to provide documentations for them :mellow: . so i though why not make a script that can take screenshot and then will tag the image with the details i will/users will provide.

this way without any external documentation the image will speak for itself that what is the bug,what are the steps we followed to get it,who was handling the module,release version and the most important thing time.

I know every 1 have reasons to be worried about it coz if we can do this god knows what data will be injected and transmitted through the images.but this is not my objective.

Please ppl i need help here.

Thnx.

Share this post


Link to post
Share on other sites

So sad, :mellow:

No one has any idea how to go about it.

anyways..Thnx guys.

Share this post


Link to post
Share on other sites

Why not save as/convert to another image format (JPG, TIFF, ...), and use e.g. exiftool to embed the information ?

hth,

wim

Share this post


Link to post
Share on other sites

Thank you a lot for your suggestion,well i have already checked out exiftool,but couldn't take it because -

1.Don't want to add any 3rd party tool.License issues might come up.and i don't want my script to be dependent.

2.The gif's are saving lots of space.though i can switch to jpeg if that serves the purpose.

3.exiftool and the other tools i saw saves mostly camera/photography related info which is not my target to capture.

any other ideas are most welcome... :mellow:

Share this post


Link to post
Share on other sites

This can be done with straight GDI+, i'm looking for a good example.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

#include <GuiConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>

; Initialize GDI+ library
_GDIPlus_Startup ()

; Capture full screen
$hBitmap = _ScreenCapture_Capture()

;Capture window
;$hWin = WinGetHandle ("SciTE")
;$hBitmap = _ScreenCapture_CaptureWnd('', $hWin)

$hImage = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap)
$hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage)

;Get dimensions
$iWidth = _GDIPlus_ImageGetWidth($hImage)
$iHeight = _GDIPlus_ImageGetHeight($hImage)
$sCLSID = _GDIPlus_EncodersGetCLSID ("JPG")

;Draw semi transparent rectangle along bottom
$hBrush1 = _GDIPlus_BrushCreateSolid(0x7F000000)
_GDIPlus_GraphicsFillRect($hGraphic, 0, $iHeight-40,$iWidth,40,$hBrush1)

;Define font
$hBrush2 = _GDIPlus_BrushCreateSolid (0xFFFFFFFF) ;Text color (white)
$hFormat = _GDIPlus_StringFormatCreate()
_GDIPlus_StringFormatSetAlign($hFormat,1) ;Center text horizontally
$hFamily = _GDIPlus_FontFamilyCreate ("Arial") ;Typeface
$hFont = _GDIPlus_FontCreate ($hFamily, 20, 1) ;Font style (20pt, bold)
$tLayout = _GDIPlus_RectFCreate (0, $iHeight-40,$iWidth,40)

;Draw text along bottom
_GDIPlus_GraphicsDrawStringEx ($hGraphic, "Hello world", $hFont, $tLayout, $hFormat, $hBrush2)

; Save resultant image (high quality)
$tParams = _GDIPlus_ParamInit (1)
$tData = DllStructCreate("int Quality")
DllStructSetData($tData, "Quality", 100) ;quality 0-100
$pData = DllStructGetPtr($tData)
_GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData)
$pParams = DllStructGetPtr($tParams)
_GDIPlus_ImageSaveToFileEx($hImage, @MyDocumentsDir & "\GDIPlus_Image.jpg", $sCLSID, $pParams)

; Save resultant image (low quality)
;_GDIPlus_ImageSaveToFile ($hImage, @MyDocumentsDir & "\GDIPlus_Image.jpg")

; Clean up resources
_GDIPlus_ImageDispose ($hImage)
_GDIPlus_GraphicsDispose($hGraphic)
_WinAPI_DeleteObject ($hBitmap)
_GDIPlus_BrushDispose($hBrush1)
_GDIPlus_BrushDispose($hBrush2)

; Shut down GDI+ library
_GDIPlus_ShutDown ()

Edited by weaponx

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  
Followers 0