[sugg/BUG?] NCONVERT plugin management: make it fool proof

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, xnview

Post Reply
User avatar
DOS386
Posts: 291
Joined: Sun Jun 11, 2006 2:43 pm

[sugg/BUG?] NCONVERT plugin management: make it fool proof

Post by DOS386 » Sun Mar 06, 2011 1:50 pm

(as started in messy thread: http://newsgroup.xnview.com/viewtopic.php?t=21685)

Problem: plugin management in NC is not very user friendly and fool-proof (+ possibly even buggy).

- Plugins are not accepted in same directory as NC
- It says "Error: Don't know how to read this picture" ... but better message would be "This format needs the plugin" (name) or "Plugin" (name) "failed" (additionally at startup: "Plugin" (name) "DLL load/init failed" or "NOT found")
- Loads same plugin 2 times (5.85: before and after opening the input file) (or even more is possible?) ??? Tries even wrong plugins (5.80) ...
- Very hard to debug, verbose option says nothing about attempts to find or use plugins

So I invented following (pseudo-code) to fix this (run at NC start, before opening any input files):

Code: Select all

X0 = GetFileAttributes ("PLUGINS")
IF (X0 says "exists and is a DIRECTORY") THEN
    PluginSearchPath="PLUGINS\" // The old known behavior 
ELSE
    PluginSearchPath="" // Look in the same directory
ENDIF
PluginIndex := 0
DO
    IF (PluginIndex says "no more plugins") THEN EXIT
    PluginName = ArrayOfPluginNames (PluginIndex)
    PluginMoHaArray (PluginIndex) := 0 // NOT available
    S1 = PluginSearchPath + PluginName + ".DLL"
    IF ("verbose") THEN PRINT "Plugin: " + S1 + " ... "
    X2 = GetFileAttributes (S1)
    IF (X2 says "exists and is a file") THEN
        X3 = LoadLibrary (S1)
        IF (X3 == "success") THEN
            PluginMoHaArray (PluginIndex) := X3 // Save Module Handle
            IF ("verbose") THEN PRINT "Loaded OK"
        ELSE
            IF ("verbose") THEN PRINT "DLL load/init failed" 
            // Most ^^^ likely some stupid 4th party DLL like
            // MSVCxxxx was not found or has wrong version :-(
        ENDIF (X3 == "success") // LoadLibrary result
    ELSE // plugin file existence
        IF ("verbose") THEN PRINT "NOT found"
    ENDIF // plugin file existence
    INC (PluginIndex)
    IF ("verbose") THEN PRINT (EOL)
LOOP
Later, when processing files, return (even if not verbose):

- "Error: Don't know how to read this picture" only if no plugin exists to handle it
- "This format needs the plugin" (name) if plugin could help, but (PluginMoHaArray (PluginIndex) == 0)
- "Plugin" (name) "failed" if plugin returned failure or GetProcAddress return "NOT found" for needed function

Example output:

---------------------------
Plugin: "webp.dll" ... Loaded OK
Plugin: "CADImage.DLL" ... NOT found
Plugin: "CS_DXF.DLL" ... NOT found
Plugin: "lwf.dll" ... NOT found
Plugin: "ldf.dll" ... DLL load/init failed
or
Plugin: "PLUGINS\webp.dll" ... Loaded OK
Plugin: "PLUGINS\CADImage.DLL" ... Loaded OK
Plugin: "PLUGINS\CS_DXF.DLL" ... Loaded OK
Plugin: "PLUGINS\lwf.dll" ... Loaded OK
Plugin: "PLUGINS\ldf.dll" ... Loaded OK
---------------------------
This format needs the plugin "WEBP.DLL"
or
Plugin "WEBP.DLL" failed
---------------------------
Last edited by DOS386 on Fri Sep 09, 2011 10:08 am, edited 1 time in total.
There is indeed no WinZIP under my rock.

User avatar
xnview
Author of XnView
Posts: 33644
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: [sugg/BUG?] NCONVERT plugin management: make it fool pro

Post by xnview » Mon Mar 07, 2011 8:13 am

DOS386 wrote: - Plugins are not accepted in same directory as NC
Nconvert use Plugin folder, not for you??
- Loads same plugin 2 times (5.85: before and after opening the input file) (or even more is possible?) ??? Tries even wrong plugins (5.80) ...
With which command?
Pierre.

User avatar
DOS386
Posts: 291
Joined: Sun Jun 11, 2006 2:43 pm

Re: [sugg/BUG?] NCONVERT plugin management: make it fool pro

Post by DOS386 » Tue Mar 08, 2011 3:50 am

xnview wrote:Nconvert use Plugin folder, not for you??
I had it in my tests ... but allowing to place plugins into same directory too would be an improvement. :-)
With which command?
I don't have it for sure (yet) ... I see the strings only ("Plugins\webp.dll" and "msvcr90.dll") ... so I suspect LoadLibrary as it re-resolves "msvcr90.dll" :?
There is indeed no WinZIP under my rock.

salma66
Posts: 1
Joined: Thu Sep 08, 2011 7:51 am

Re: [sugg/BUG?] NCONVERT plugin management: make it fool pro

Post by salma66 » Thu Sep 08, 2011 7:53 am

Are there any news on the topic by now? :?:
JMK Design
Last edited by salma66 on Mon Jun 24, 2013 12:53 pm, edited 1 time in total.

User avatar
DOS386
Posts: 291
Joined: Sun Jun 11, 2006 2:43 pm

Re: [sugg/BUG?] NCONVERT plugin management: make it fool pro

Post by DOS386 » Fri Sep 09, 2011 10:07 am

salma66 wrote:Are there any news on the topic by now? :?:
Heh, someone answered ;-)
There is indeed no WinZIP under my rock.

Post Reply