Jump to content

_GDIPlus_ImageLoadFromFile() meaning of @error = 10 and @extended = 3


Recommended Posts

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

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 post
Share on other sites
Posted (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 by dejhost
added comment
Link to post
Share on other sites

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 post
Share on other sites
Link to post
Share on other sites
#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 post
Share on other sites

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.

...
    $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 by pixelsearch
Link to post
Share on other sites
Posted (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 by dejhost
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...