Jump to content

JPEG/JPG image resize


rony2006
 Share

Recommended Posts

Look in the help for for

  • _GDIPlus_ImageLoadFromFile
  • _GDIPlus_ImageResize / _GDIPlus_ImageScale
  • _GDIPlus_ImageSaveToFile

 

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

GDIPlus supported images types: BMP, GIF, JPEG, PNG, TIFF, Exif, WMF, and EMF.

 

When you want to save just add a valid extension to save the bitmap in that format!

Example: _GDIPlus_ImageSaveToFile ( $hImage, @ScriptDir & "\MyBitmap.jpg" )

 

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

Hello,

After reading your replay I made the following script but is not working. I don't have any error but the image is not resized and not saved to @ScriptDir & "\MyBitmap.jpg" )

Can you help me please?

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>




Example()

Func Example()
    ; Create a constant variable in Local scope of the message to display in FileOpenDialog.
    Local Const $sMessage = "Hold down Ctrl or Shift to choose multiple files."

    ; Display an open dialog to select a list of file(s).
    Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "Images (*.jpg;*.jpeg)|Videos (*.avi;*.mpg)", $FD_FILEMUSTEXIST + $FD_MULTISELECT)
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.")

        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)
    Else
        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)

        ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog.
        $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF)

        ; Display the list of selected files.
        MsgBox($MB_SYSTEMMODAL, "", "You chose the following files:" & @CRLF & $sFileOpenDialog)
    EndIf
    
    
    FileCopy($sFileOpenDialog, "D:\test\poza.jpg")
    
EndFunc   ;==>Example

global $hBitmap = "D:\test\poza.jpg"

_GDIPlus_Startup()
 Local Const $iW = @DesktopWidth, $iH = @DesktopHeight
_GDIPlus_ImageResize($hBitmap, $iW / 4, $iH / 4) ;resize image
_GDIPlus_ImageSaveToFile ($hBitmap, @ScriptDir & "\MyBitmap.jpg" )

 

Link to comment
Share on other sites

Try these lines at the end instead::

Global $sBitmap = "D:\test\poza.jpg"

_GDIPlus_Startup()
Global Const $iW = @DesktopWidth, $iH = @DesktopHeight
Global $hBitmap = _GDIPlus_ImageLoadFromFile($sBitmap)
Global $hBitmap_Resized = _GDIPlus_ImageResize($hBitmap, $iW / 4, $iH / 4) ;resize image
_GDIPlus_ImageSaveToFile ($hBitmap_Resized, @ScriptDir & "\MyBitmap.jpg" )
_GDIPlus_ImageDispose($hBitmap)
_GDIPlus_ImageDispose($hBitmap_Resized)
_GDIPlus_Shutdown()

 

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...