Deye Posted May 1, 2023 Share Posted May 1, 2023 Not figure out yet , any help with this will be great Thank you #include <WinAPIShellEx.au3> #include <GDIPlus.au3> ShellExecute(ImageTOGreyscale("image.jpg")) Func ImageTOGreyscale($img) _GDIPlus_Startup() Local $hIA = _GDIPlus_ImageAttributesCreate() ;create an ImageAttribute object Local $tColorMatrix = _GDIPlus_ColorMatrixCreateGrayScale() ;create grayscale color matrix _GDIPlus_ImageAttributesSetColorMatrix($hIA, 4, True, $tColorMatrix, 1) ;set negative color matrix Local $hImage1 = _GDIPlus_ImageLoadFromFile(@ScriptFullPath & "\" & $img) $ext = StringRegExpReplace($img, "^.*\.", "") $file = StringRegExpReplace(@ScriptFullPath, "(^.*\\)(.*)", "\1") & "img_grey." & $ext ;~ ClipPut($file) ;~ MsgBox(0, '', $file) $sCLSID = _GDIPlus_EncodersGetCLSID($ext) MsgBox(0, 'creating img_grey.' & $ext, _GDIPlus_ImageSaveToFileEx($hImage1, $file, $sCLSID)) _GDIPlus_ImageAttributesDispose($hIA) _GDIPlus_ImageDispose($hImage1) _GDIPlus_Shutdown() Return $file EndFunc ;==>ImageTOGreyscale Link to comment Share on other sites More sharing options...
ioa747 Posted May 1, 2023 Share Posted May 1, 2023 for start, replace @ScriptFullPath with @ScriptDir Deye 1 I know that I know nothing Link to comment Share on other sites More sharing options...
Werty Posted May 1, 2023 Share Posted May 1, 2023 (edited) Check out this old thread... Edited May 1, 2023 by Werty Deye 1 Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
Solution Skeletor Posted May 3, 2023 Solution Share Posted May 3, 2023 (edited) I took some inspiration from this post. They used a screen capture, I modified the script to rather open an image. Try this: expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 #include <GDIPlus.au3> Example() Func Example() _GDIPlus_Startup() Local $sInputFile = "image.jpg" Local $sOutputFile = "image_gray.jpg" Local $hImage = _GDIPlus_ImageLoadFromFile($sInputFile) If Not $hImage Then ConsoleWriteError("Failed to load image: " & $sInputFile & @CRLF) Return False EndIf Local Const $iWidth = _GDIPlus_ImageGetWidth($hImage) Local Const $iHeight = _GDIPlus_ImageGetHeight($hImage) Local $hIA = _GDIPlus_ImageAttributesCreate() Local $tColorMatrix = _GDIPlus_ColorMatrixCreateGrayScale() _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tColorMatrix) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight) _GDIPlus_GraphicsDispose($hGraphics) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) _GDIPlus_ImageSaveToFile($hBitmap, $sOutputFile) _GDIPlus_ImageAttributesDispose($hIA) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_ImageDispose($hImage) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() EndFunc ;==>Example Edited May 3, 2023 by Skeletor Deye 1 Kind RegardsSkeletor "Coffee: my defense against going postal." Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now