Jump to content

jpg to gif


rajah
 Share

Recommended Posts

Hello

please is there any way to embed jpg pictures into a gif ?

i mean, for exemple i have 25 images ...

i want to turn them into an animated gif

I love to program, and if I ever lose that love, I will no longer be a programmer.

It will be a sad day.

Link to comment
Share on other sites

Try GifcamEx

You can create an animated gif frame by frame

​well, thank's about your reply wakillon, i lready maked a lot of gifs with gifcamex, but i need to know how can i record my full screen with my script, gifcamex code is too long and i cant figure out how can i do it

I love to program, and if I ever lose that love, I will no longer be a programmer.

It will be a sad day.

Link to comment
Share on other sites

If you have Vista or a higher OS you can try _GDIPlus_GIFAnim.au3. The 3rd example is how to create a GIF with screenshots. It is very easy to modify the example to add images from disk instead.

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 comment
Share on other sites

If you have Vista or a higher OS you can try _GDIPlus_GIFAnim.au3. The 3rd example is how to create a GIF with screenshots. It is very easy to modify the example to add images from disk instead.

​Thanks about your reply UEZ

i will try it now

I love to program, and if I ever lose that love, I will no longer be a programmer.

It will be a sad day.

Link to comment
Share on other sites

If you have Vista or a higher OS you can try _GDIPlus_GIFAnim.au3. The 3rd example is how to create a GIF with screenshots. It is very easy to modify the example to add images from disk instead.

​bro, the script is working, but there is 2 problems

the record is animating, it's looks like a movie maker effect or something, but the bigest problem is the size  ! 12 mbs for 10 sec of recording !

how can i reduce the suality of capturing please ?

I love to program, and if I ever lose that love, I will no longer be a programmer.

It will be a sad day.

Link to comment
Share on other sites

What about the images your are using? Which dimension? GIF images are always 8-bit (256 colors). With difthering the size will increase.

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 comment
Share on other sites

What about the images your are using? Which dimension? GIF images are always 8-bit (256 colors). With difthering the size will increase.

​WHATS WRONG WITH THIS CODE ?

im trying to make the frames smaller

and i get this in console

False:1
Animation created in 1225.96303848811 ms (8 fps).
+>11:59:03 AutoIt3.exe ended.rc:0
+>11:59:03 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 2.495

#include <Screencapture.au3>
#include "_GDIPlus_GIFAnim.au3"

_GDIPlus_Startup()

Global $iFrames = 10, $aImages[$iFrames + 1] = [$iFrames], $sSave = @ScriptDir & "\Test.gif", $i, $hHBitmap, $iW = @DesktopWidth, $iH = @DesktopHeight, $iX, $iY, $a = 1
;~ Global $aImages[361] = [360], $sSave = "C:\Temp\Test.gif", $i
Global $fEnd, $fTimer = TimerInit()
For $i = 1 To $aImages[0]
$Quality = 1

    $iX = $i * $a
    $a *= 1.0075
    $iY = 0
    _ScreenCapture_SetJPGQuality ($Quality)

    $hHBitmap = _ScreenCapture_Capture("", $iX, $iY, $iX + $iW, $iY + $iH) ;L, T, R, B
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap)
    $hImage2 = _GDIPlus_ImageResize($hImage1, $iW / 2, $iH / 2)
    
    $aImages[$i] = _GDIPlus_BitmapCreateFromHBITMAP($hImage2)
    _GDIPlus_BitmapConvertTo8Bit($aImages[$i], 255, $GDIP_DitherTypeDualSpiral8x8)
    _WinAPI_DeleteObject($hHBitmap)
Next
ConsoleWrite(_GDIPlus_GIFAnimCreateFile($aImages, $sSave, 5) & ":" & @error & @CRLF) ;40 -> 25 fps (25 * 40 = 1000)
$fEnd = TimerDiff($fTimer)
ConsoleWrite("Animation created in " & $fEnd & " ms (" & Int($aImages[0] / $fEnd * 1000) & " fps)." & @CRLF)

For $i = 1 To $aImages[0]
    _GDIPlus_ImageDispose($aImages[$i])
Next
_GDIPlus_Shutdown()

 

I love to program, and if I ever lose that love, I will no longer be a programmer.

It will be a sad day.

Link to comment
Share on other sites

I will have a look later because now I've to do some work at home.

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 comment
Share on other sites

I will have a look later because now I've to do some work at home.

​allrighty, i'm waiting for you

I love to program, and if I ever lose that love, I will no longer be a programmer.

It will be a sad day.

Link to comment
Share on other sites

You are not thinking properly with reducing the size using JPG quality!

For example when I take a screenshot from my desktop (1600x900) and save it as JPG with quality 50 the filesize is around 95 kb. When saving the bitmap as GIF the filesize is around 375 kb.

In your code it makes no sense to set any JPG quality because the screen will be captured to the memory in GDI bitmap format without any quality loss, converted to GDI+ bitmap format and finally the bitmap depth will be reduced to a 8-bit color depth.

Thus you have to reduce the bitmap size and/or the color depth of the bitmap:

;creates a GIF animation file
#AutoIt3Wrapper_UseX64=n
;~ #AutoIt3Wrapper_Version=b

#include <Screencapture.au3>
#include "_GDIPlus_GIFAnim.au3"
If @OSBuild < 6000 Then Exit MsgBox(16, "ERROR", "Vista or a higher operating system is required to create a GIF animation!", 30)

_GDIPlus_Startup()

Global $iFrames = 250, $aImages[$iFrames + 1] = [$iFrames], $sSave = @ScriptDir & "\Test.gif", $i, $hHBitmap, $iW = @DesktopWidth, $iH = @DesktopHeight, _
       $iX = 0, $iY = 0, $i

Global $fEnd, $fTimer = TimerInit()
For $i = 1 To $aImages[0]
    $hHBitmap = _ScreenCapture_Capture("", $iX, $iY, $iX + $iW, $iY + $iH) ;L, T, R, B
    $hBmp = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap)
    $aImages[$i] = _GDIPlus_ImageScale($hBmp, 0.2, 0.2)
    _GDIPlus_BitmapDispose($hBmp)
    _GDIPlus_BitmapConvertTo8Bit($aImages[$i], 256, $GDIP_DitherTypeSolid)
    _WinAPI_DeleteObject($hHBitmap)
Next
ConsoleWrite(_GDIPlus_GIFAnimCreateFile($aImages, $sSave, 40) & ":" & @error & @CRLF) ;40 -> 25 fps (25 * 40 = 1000)
$fEnd = TimerDiff($fTimer)
ConsoleWrite("Animation created in " & $fEnd & " ms (" & Int($aImages[0] / $fEnd * 1000) & " fps)." & @CRLF)

For $i = 1 To $aImages[0]
    _GDIPlus_ImageDispose($aImages[$i])
Next
_GDIPlus_Shutdown()

 

This will create a GIF animation from your desktop with 40 ms delay but the screensize will be reduced to 20%.

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 comment
Share on other sites

You are not thinking properly with reducing the size using JPG quality!

For example when I take a screenshot from my desktop (1600x900) and save it as JPG with quality 50 the filesize is around 95 kb. When saving the bitmap as GIF the filesize is around 375 kb.

In your code it makes no sense to set any JPG quality because the screen will be captured to the memory in GDI bitmap format without any quality loss, converted to GDI+ bitmap format and finally the bitmap depth will be reduced to a 8-bit color depth.

Thus you have to reduce the bitmap size and/or the color depth of the bitmap:

;creates a GIF animation file
#AutoIt3Wrapper_UseX64=n
;~ #AutoIt3Wrapper_Version=b

#include <Screencapture.au3>
#include "_GDIPlus_GIFAnim.au3"
If @OSBuild < 6000 Then Exit MsgBox(16, "ERROR", "Vista or a higher operating system is required to create a GIF animation!", 30)

_GDIPlus_Startup()

Global $iFrames = 250, $aImages[$iFrames + 1] = [$iFrames], $sSave = @ScriptDir & "\Test.gif", $i, $hHBitmap, $iW = @DesktopWidth, $iH = @DesktopHeight, _
       $iX = 0, $iY = 0, $i

Global $fEnd, $fTimer = TimerInit()
For $i = 1 To $aImages[0]
    $hHBitmap = _ScreenCapture_Capture("", $iX, $iY, $iX + $iW, $iY + $iH) ;L, T, R, B
    $hBmp = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap)
    $aImages[$i] = _GDIPlus_ImageScale($hBmp, 0.2, 0.2)
    _GDIPlus_BitmapDispose($hBmp)
    _GDIPlus_BitmapConvertTo8Bit($aImages[$i], 256, $GDIP_DitherTypeSolid)
    _WinAPI_DeleteObject($hHBitmap)
Next
ConsoleWrite(_GDIPlus_GIFAnimCreateFile($aImages, $sSave, 40) & ":" & @error & @CRLF) ;40 -> 25 fps (25 * 40 = 1000)
$fEnd = TimerDiff($fTimer)
ConsoleWrite("Animation created in " & $fEnd & " ms (" & Int($aImages[0] / $fEnd * 1000) & " fps)." & @CRLF)

For $i = 1 To $aImages[0]
    _GDIPlus_ImageDispose($aImages[$i])
Next
_GDIPlus_Shutdown()

 

This will create a GIF animation from your desktop with 40 ms delay but the screensize will be reduced to 20%.

​That's exactly what i was looking for :)

so, can you tel me how can i reduce the frame rate sir ?

I love to program, and if I ever lose that love, I will no longer be a programmer.

It will be a sad day.

Link to comment
Share on other sites

You have to do some math.

 1 second = 1000 miliseconds

E.g. you want 5 frames per second (fps) -> 1000 / 5 = 200. Use _GDIPlus_GIFAnimCreateFile($aImages, $sSave, 200) to create the GIF anim using 5 fps or a delay with 200ms between each frame.

 

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 comment
Share on other sites

You have to do some math.

 1 second = 1000 miliseconds

E.g. you want 5 frames per second (fps) -> 1000 / 5 = 200. Use _GDIPlus_GIFAnimCreateFile($aImages, $sSave, 200) to create the GIF anim using 5 fps or a delay with 200ms between each frame.

 

​Great ! you are so fast man

respect ...

I love to program, and if I ever lose that love, I will no longer be a programmer.

It will be a sad day.

Link to comment
Share on other sites

  • 4 years later...
  • 3 weeks later...
40 minutes ago, swirlyEyes said:

How do make the GIF loop infinately? Currently it just plays through once.

Create a loop. When the end of the frames has been reached just set it to the first frame again.

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 comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...