rony2006

JPEG/JPG image resize

10 posts in this topic

Hello, can you give me an example of how I can resize a JPEG/JPG file and then store in another folder?

 

Thanks!

Share this post


Link to post
Share on other sites



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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thank you, but _GDIPlus_ImageResize can also work with JPEG/JPG?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
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" )

 

Share this post


Link to post
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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thank you guys!

But I have a little problem: if i have changed

"D:\test\poza.jpg"

with \test\poza.jpg , my picture is still saved in

"D:\test\poza.jpg"

 

Why is this happen?

 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

can someone help me please?

i still get the same problem even if i restart the pc

Edited by rony2006

Share this post


Link to post
Share on other sites

Try with full path instead of a partial path.


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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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