dejhost Posted March 19, 2021 Share Posted March 19, 2021 Hi! I am getting an error when loading images using _GDIPlus_ImageLoadFromFile(). Where may I find a list that tell me the meaning of the vaules for @error and @extended? Currently, I receive @error = 10 and @extended = 3. Thanks! Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 19, 2021 Share Posted March 19, 2021 @dejhost You can find the value of the @extended here, but you might post your script so people can assist you more Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
UEZ Posted March 19, 2021 Share Posted March 19, 2021 1) Did you startup GDIPlus using _GDIPlus_Startup() before any GDIPlus call? 2) What file type are you trying to load? 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 More sharing options...
dejhost Posted March 19, 2021 Author Share Posted March 19, 2021 (edited) Thank you for the link and your offer. @extended = 3 means "Out of memory"... I don't think that this is the true problem here. @UEZ: Yes, _GDIPlus_Startup() is started up in the beginning. at the moment, it's only jpgs. Func resize_and_save_image($iname_long, $iname_short, $newwidth, $newheight) $hBitmap = _GDIPlus_ImageLoadFromFile($iname_long) If @error <> 0 Then ConsoleWrite("Line: " & @ScriptLineNumber & " @error: " & @error & " @extended: " & @extended & " _GDIPlus_ImageLoadFromFile()" & " $iname_long: " & $iname_long & @CRLF) ;resize image Local $hBitmap_Resized = _GDIPlus_ImageResize($hBitmap, $newwidth, $newheight) ;resize image If @error <> 0 Then ConsoleWrite("Line: " & @ScriptLineNumber & " @error: " & @error & " @extended: " & @extended & " _GDIPlus_ImageResize()" & " $hBitmap: " & $hBitmap & " $newwidth: " & $newwidth & " $newheight: " & $newheight & @CRLF) If $sep = $seperator Then _GDIPlus_ImageSaveToFile($hBitmap_Resized, $testfolder & $iname_short) If @error <> 0 Then ConsoleWrite("Line: " & @ScriptLineNumber & " @error: " & @error & " @extended: " & @extended & " _GDIPlus_ImageSaveToFile()" & " $hBitmap_Resized: " & $hBitmap_Resized & " $testfolder & $iname_short " & $testfolder & $iname_short & @CRLF) $sep = 0 ; resets the counter $sep: files have been copied to test-folder. Next set of files go to train-folder again Else _GDIPlus_ImageSaveToFile($hBitmap_Resized, $trainfolder & $iname_short) If @error <> 0 Then ConsoleWrite("Line: " & @ScriptLineNumber & " @error: " & @error & " @extended: " & @extended & " _GDIPlus_ImageSaveToFile()" & " $hBitmap_Resized: " & $hBitmap_Resized & " $testfolder & $iname_short " & $testfolder & $iname_short & @CRLF) EndIf _GDIPlus_ImageDispose($hBitmap) _GDIPlus_ImageDispose($hBitmap_Resized) EndFunc ;==>resize_and_save This Function processes 500 images. Most of them don't cause errors. The console write delivers: Line: 330 @error: 10 @extended: 3_GDIPlus_ImageLoadFromFile() $iname_long: C:\Users\dejhost\Documents\RnD\n101_0408.jpg Line: 336 @error: 4 @extended: 0_GDIPlus_ImageResize() $hBitmap: 0 $newwidth: 3084 $newheight: 2048 Line: 344 @error: 10 @extended: 2_GDIPlus_ImageSaveToFile()$hBitmap_Resized: 0 $testfolder & $iname_short C:\Users\dejhost\Downloads\transfer\test\n101_0408.jpg Line: 336 @error: 4 @extended: 0_GDIPlus_ImageResize() $hBitmap: 0x0EE5BF48 $newwidth: 3084 $newheight: 2048 Line: 344 @error: 10 @extended: 2_GDIPlus_ImageSaveToFile()$hBitmap_Resized: 0 $testfolder & $iname_short C:\Users\dejhost\Downloads\transfer\test\n101_0265.jpg Line: 336 @error: 4 @extended: 0_GDIPlus_ImageResize() $hBitmap: 0x0EE5BF48 $newwidth: 3084 $newheight: 2048 Line: 344 @error: 10 @extended: 2_GDIPlus_ImageSaveToFile()$hBitmap_Resized: 0 $testfolder & $iname_short C:\Users\dejhost\Downloads\transfer\test\n101_0260.jpg Line: 336 @error: 4 @extended: 0_GDIPlus_ImageResize() $hBitmap: 0x0EE59B30 $newwidth: 3084 $newheight: 2048 Line: 344 @error: 10 @extended: 2_GDIPlus_ImageSaveToFile()$hBitmap_Resized: 0 $testfolder & $iname_short C:\Users\dejhost\Downloads\transfer\test\n101_0258.jpg Line: 336 @error: 1 @extended: 0_GDIPlus_ImageResize() $hBitmap: 0x0EE55CD8 $newwidth: 3084 $newheight: 2048 Line: 344 @error: 10 @extended: 2_GDIPlus_ImageSaveToFile()$hBitmap_Resized: 0 $testfolder & $iname_short C:\Users\dejhost\Downloads\transfer\test\n101_0269.jpg Line: 336 @error: 1 @extended: 0_GDIPlus_ImageResize() $hBitmap: 0x0EE59E78 $newwidth: 3084 $newheight: 2048 Line: 340 @error: 10 @extended: 2_GDIPlus_ImageSaveToFile()$hBitmap_Resized: 0 $testfolder & $iname_short C:\Users\dejhost\Downloads\transfer\test\n101_0259.jpg Line: 336 @error: 1 @extended: 0_GDIPlus_ImageResize() $hBitmap: 0x0EE5AEE0 $newwidth: 3084 $newheight: 2048 Line: 344 @error: 10 @extended: 2_GDIPlus_ImageSaveToFile()$hBitmap_Resized: 0 $testfolder & $iname_short C:\Users\dejhost\Downloads\transfer\test\n101_0257.jpg Line: 336 @error: 1 @extended: 0_GDIPlus_ImageResize() $hBitmap: 0x0EE5B228 $newwidth: 3084 $newheight: 2048 Line: 344 @error: 10 @extended: 2_GDIPlus_ImageSaveToFile()$hBitmap_Resized: 0 $testfolder & $iname_short C:\Users\dejhost\Downloads\transfer\test\n101_0256.jpg Line: 330 @error: 10 @extended: 3_GDIPlus_ImageLoadFromFile() $iname_long: C:\Users\dejhost\Documents\RnD\n101_0266.jpg Line: 336 @error: 1 @extended: 0_GDIPlus_ImageResize() $hBitmap: 0 $newwidth: 3084 $newheight: 2048 Line: 344 @error: 10 @extended: 2_GDIPlus_ImageSaveToFile()$hBitmap_Resized: 0 $testfolder & $iname_short C:\Users\dejhost\Downloads\transfer\test\n101_0266.jpg Line: 330 @error: 10 @extended: 3_GDIPlus_ImageLoadFromFile() $iname_long: C:\Users\dejhost\Documents\RnD\n101_0251.jpg Line: 336 @error: 1 @extended: 0_GDIPlus_ImageResize() $hBitmap: 0 $newwidth: 3084 $newheight: 2048 Line: 344 @error: 10 @extended: 2_GDIPlus_ImageSaveToFile()$hBitmap_Resized: 0 $testfolder & $iname_short C:\Users\dejhost\Downloads\transfer\test\n101_0251.jpg Line: 330 @error: 10 @extended: 3_GDIPlus_ImageLoadFromFile() $iname_long: C:\Users\dejhost\Documents\RnD\n101_0255.jpg Line: 336 @error: 1 @extended: 0_GDIPlus_ImageResize() $hBitmap: 0 $newwidth: 3084 $newheight: 2048 Line: 340 @error: 10 @extended: 2_GDIPlus_ImageSaveToFile()$hBitmap_Resized: 0 $testfolder & $iname_short C:\Users\dejhost\Downloads\transfer\test\n101_0255.jpg Line: 330 @error: 10 @extended: 3_GDIPlus_ImageLoadFromFile() $iname_long: C:\Users\dejhost\Documents\RnD\n101_0252.jpg Line: 336 @error: 1 @extended: 0_GDIPlus_ImageResize() $hBitmap: 0 $newwidth: 3084 $newheight: 2048 Line: 344 @error: 10 @extended: 2_GDIPlus_ImageSaveToFile()$hBitmap_Resized: 0 $testfolder & $iname_short C:\Users\dejhost\Downloads\transfer\test\n101_0252.jpg !>11:30:10 AutoIt3.exe ended.rc:-1073741395 +>11:30:10 AutoIt3Wrapper Finished. >Exit code: 3221225901 Time: 586.8 I will check if I can find something suspicious in these images. Edited March 19, 2021 by dejhost added comment Link to comment Share on other sites More sharing options...
Nine Posted March 19, 2021 Share Posted March 19, 2021 Probably memory leak. Have you checked memory usage of this process in Task Manager ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
dejhost Posted March 19, 2021 Author Share Posted March 19, 2021 Memory is steady below 25%. The image "n101_0408.jpg" had a broken header, so I removed it from the list of images to process. All other images seem ok. I inserted a "return", in case an error happens. So if we start with the first error: Local $hBitmap_Resized = _GDIPlus_ImageResize($hBitmap, $newwidth, $newheight) ;resize image causes Line: 340 @error: 4 @extended: 0 _GDIPlus_ImageResize() $hBitmap: 0x0EE70AD0 $newwidth: 3084 $newheight: 2048 @error 4 means: "unable to copy image to scaled bitmap" Any idea what the reason might be? Link to comment Share on other sites More sharing options...
dejhost Posted March 19, 2021 Author Share Posted March 19, 2021 Here's a link to the file in question: https://nextcloud.subseascanning.com/s/CRoJCcWSCaFrpRP Maybe somebody could test it? Link to comment Share on other sites More sharing options...
Nine Posted March 19, 2021 Share Posted March 19, 2021 7 minutes ago, dejhost said: Maybe somebody could test it? I will if you can provide a runable script “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
dejhost Posted March 19, 2021 Author Share Posted March 19, 2021 #include <GDIPlus.au3> _GDIPlus_Startup() Local $iname_long = "path\to\image\n101_0265.jpg" Local $newwidth = 3084 Local $newheight = 2048 ;load image Local $hBitmap = _GDIPlus_ImageLoadFromFile($iname_long) If @error <> 0 Then ConsoleWrite("Line: " & @ScriptLineNumber & " @error: " & @error & " @extended: " & @extended & " _GDIPlus_ImageLoadFromFile()" & " $iname_long: " & $iname_long & @CRLF) EndIf ;resize image Local $hBitmap_Resized = _GDIPlus_ImageResize($hBitmap, $newwidth, $newheight) ;resize image If @error <> 0 Then ConsoleWrite("Line: " & @ScriptLineNumber & " @error: " & @error & " @extended: " & @extended & " _GDIPlus_ImageResize()" & " $iname_long: " & $iname_long & " $hBitmap: " & $hBitmap & " $newwidth: " & $newwidth & " $newheight: " & $newheight & @CRLF) Mhmmm, none of the images are causing any troubles when I run this script. So many trees... but where is the forest? Link to comment Share on other sites More sharing options...
pixelsearch Posted March 19, 2021 Share Posted March 19, 2021 (edited) When I downloaded the pic you indicated us (nextcloud link) then it was saved under this name : 1024-680.jpg Anyway, I could resize it without error to the new dimensions you indicated. Concerning the error you're talking about : 5 hours ago, dejhost said: Line: 340 @error: 4 @extended: 0 _GDIPlus_ImageResize() $hBitmap: 0x0EE70AD0 $newwidth: 3084 $newheight: 2048 I already encountered this error when the image can be opened without error (i.e. _GDIPlus_ImageLoadFromFile succeeds) but it can't be resized. I treat this kind of picture like this, even if there are other pictures waiting to be resized. expandcollapse popup... $hImage_resized = _GDIPlus_ImageResize($hImage, $iX_resized, $iY_resized) If @error Then ; damaged image (tried it: @error = 4 and @extended =0) $iKeep_error = @error $iKeep_extended = @extended If Not ($iKeep_error = 4 And $iKeep_extended = 0) Then _Quit("_GDIPlus_ImageResize", $sFileName, $iKeep_error, $iKeep_extended) Else ; $iKeep_error = 4 And $iKeep_extended = 0 : damaged image _GDIPlus_ImageDispose($hImage) $aSummary[6][0] += 1 ; skipped (resize error : damaged image) $aSummary[6][2] &= $iNum_img & "," ContinueLoop ; treat next image EndIf EndIf ... ;==================================================== Func _Quit($sError_title, $sError_msg, $iKeep_error, $iKeep_extended) ; bad error MsgBox($MB_TOPMOST, "Error : " & $sError_title, _ $sError_msg & @CRLF & @CRLF & _ "@error = " & $iKeep_error & " @extended = " & $iKeep_extended) _Exit() EndFunc ; _Quit() ;==================================================== Func _Exit() ToolTip("") AdlibStop() ;~ SplashOff() _GDIPlus_ImageDispose($hImage_resized) _GDIPlus_ImageDispose($hResized_1st_backup) _GDIPlus_ImageDispose($hImage_backup) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() If $hGUI_Preview Then GUIDelete($hGUI_Preview) If $hGUI_Background Then GUIDelete($hGUI_Background) GUIDelete($hGUI_Main) DllClose($hShell32) ; used by _WinAPI_DragQueryFileEx2() Exit EndFunc ; _Exit() These image errors are really tricky, glad for you that it works now, you'll sure find why it didn't work the 1st time, it's just a matter of... time Edited March 19, 2021 by pixelsearch FrancescoDiMuro 1 Link to comment Share on other sites More sharing options...
dejhost Posted March 23, 2021 Author Share Posted March 23, 2021 (edited) Sorry for the late reply. It only works if I process the images individually (using my script posted on Friday at 06:47). It does still not work when processing all images at once. So the issue is still not solved for me. I am grateful for your script. I'd like to try it. What is $iNum_img? Edited March 23, 2021 by dejhost 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