Any saveGIFtoFile function? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pk23
Posts: 110
Joined: 24 Apr 2015, 00:49

Any saveGIFtoFile function?

05 Apr 2017, 01:31

I am using a function, it saves the picture in the clipboard to the file, but unfortunately it does not support GIF format, is there any ways, to make it support GIF?

Code: Select all

;need GDI+ standard library
saveImagetoFile(pathwithoutSlash, ext := "png", open := false) {
	If !pToken := Gdip_Startup()
	{
		MsgBox, 48, gdiplus Error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
		ExitApp
	}
	pBitmap:=Gdip_CreateBitmapFromClipboard()
	FilePath := pathwithoutSlash "." ext
	Gdip_SaveBitmapToFile(pBitmap, FilePath)	
	Gdip_DisposeImage(pBitmap)
	Gdip_Shutdown(pToken)
	if ( open = true )
		Run, %FilePath%
	return FilePath
}
User avatar
FanaticGuru
Posts: 1906
Joined: 30 Sep 2013, 22:25

Re: Any saveGIFtoFile function?  Topic is solved

05 Apr 2017, 14:25

Your script works for me.

I run this line saveimagetofile(A_Desktop "/Temp/PictureTest", "gif") and it saved a picture that I put on the clipboard by screen clipping as a "GIF" with no problems.

Just for the record Gdip_SaveBitmapToFile and the underlying GDI+ does support "GIF" pictures.

Now if you are talking about an animated GIF that is a different beast. That is a video with multiple frames. As soon as you do Gdip_CreateBitmapFromClipboard() you are going to have a bitmap which is one pictures and does not contain the multiple frames of video that is required to create an animation.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
pk23
Posts: 110
Joined: 24 Apr 2015, 00:49

Re: Any saveGIFtoFile function?

07 Apr 2017, 22:14

FanaticGuru wrote:Your script works for me.

I run this line saveimagetofile(A_Desktop "/Temp/PictureTest", "gif") and it saved a picture that I put on the clipboard by screen clipping as a "GIF" with no problems.

Just for the record Gdip_SaveBitmapToFile and the underlying GDI+ does support "GIF" pictures.

Now if you are talking about an animated GIF that is a different beast. That is a video with multiple frames. As soon as you do Gdip_CreateBitmapFromClipboard() you are going to have a bitmap which is one pictures and does not contain the multiple frames of video that is required to create an animation.

FG
Indeed, I was trying to operate the animated gif, I googled and found that animated gif is not actually stored in the clipboard, but only stored a path basically.
I think I'm gonna give up deal with this problem. Thank you @FanaticGuru

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Joey5, mikeyww, wpulford and 369 guests