|
Post by (X) on Oct 10, 2023 11:42:59 GMT 1
DIM commandline$ DIM result
' Set the path to the IrfanView executable and the input/output file paths commandline$ = "C:\Program Files\IrfanView\i_view64.exe C:\path\to\input.png /convert=C:\path\to\output.jpg"
' Execute the command using the Exec() function result = EXEC(commandline$)
' Check the result of the execution IF result = 0 THEN PRINT "Conversion successful" ELSE PRINT "Conversion failed" ENDIF
|
|
|
Post by (X) on Oct 10, 2023 12:05:53 GMT 1
This seems to work. Granted; many tweaks are required to make it "nice"... The failed appraisal is based on the result being '0'... but, the conversion works, so, the pass/fail condition needs to be revised and understood.
$Library "gfawinx" $Library "UpdateRT" UpdateRuntime ' Patches GfaWin23.Ocx
Dim commandline$ Dim result%
' Set the path to the IrfanView executable and the input/output file paths Dim command$ = "C:\Program Files\IrfanView\i_view64.exe" Dim parameters$ = App.Path & "\input.png /convert=" & App.Path & "\output.jpg"
' Execute the command using the Exec() function result = Exec(command$, parameters$)
' Check the result of the execution If result == 0 Then Print "Conversion successful" Else Print "Conversion failed" EndIf
|
|
|
Post by (X) on Oct 10, 2023 13:04:56 GMT 1
More & better '################################################################################# ' ' DISCLAIMER: THIS CODE IS OFFERED AS IS FOR EDUCATIONAL PURPOSES. ' YOU ARE FREE TO USE, COPY AND DISTRIBUTE. ' THE USE OF THIS CODE IS AT YOUR OWN RISK. ' I ACCEPT NO LIABILITY NOR MAKE ANY CLAIM OF ' CORRECTNESS OR SUITABILITY IN PART OR IN WHOLE. ' '################################################################################# ' ' FILENAME Demo PNG to JPG IrfanView.G32 ' ' DESCRIPTION Just what it looks like, converts a PNG to JPG using IrfanView. ' ' AUTHOR (X) ' EMAIL xman.gb32@gmail.com ' WEBSITE https://gfabasic32.blogspot.com/ ' FORUM https://gb32.proboards.com/ ' STARTED 2023-10-10 ' UPDATED <ISO date> ' '#################################################################################
$Library "gfawinx" $Library "UpdateRT" UpdateRuntime ' Patches GfaWin23.Ocx Mode Date "-" OpenW 1 , 10, 10, 600, 250 : TitleW 1, App.Name : AutoRedraw = 1 FontSize = 12 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Set the path to the IrfanView executable and the input/output file paths ' Dim Executable$ = "i_view64.exe" Dim Src_Dir$ = App.Path & "\" Dim Dst_Dir$ = App.Path & "\" Dim InputFile$ = "input.png" Dim OutputFile$ = "ouptut.jpg" Dim Parameters$ = Src_Dir$ & InputFile$ & " /convert=" & Dst_Dir$ & OutputFile$ Dim Exec_Dir$ = "C:\Program Files\IrfanView\" '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' From GFA Help Doc... ' ' ShellExec Function ' ' PURPOSE ' Opens, explores, or prints a specified file or folder. ' ' SYNTAX ' x% = ShellExec(file$ [, parameters$][, exec_dir$]) ' x% = ShellExec([operation$][, file$][, parameters$][, exec_dir$] [,show%]) ' ShellExec file$ [, parameters$][, exec_dir$] ' ShellExec [operation$][, file$][, parameters$][, exec_dir$] [,show%] ' ' DESCRIPTION ' Returns a value greater than 32 if successful, or an error value that is less ' than or equal to 32 otherwise. ' Dim t0# = Timer Dim result% = ShellExec(Executable$, Parameters$, Exec_Dir$)
Print Print " CONVERT AN IMAGE FILE FROM PNG TO JPG FORMAT USING IRFANVIEW." Print Print " Input:", #34 & InputFile$ & #34 Print " Output:", #34 & OutputFile$ & #34 Print " Conversion Stats:"
If (result > 32) Print , "Success." Print , "Time (s): ", Format(Timer - t0, "0.##0"); " s" Else Print , "Failed." EndIf
Print , "Code:", "("; Format(result%); ")"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Show the output image... ' OpenW 2, 10, 260, 400, 200 : TitleW 2, "OUTPUT IMAGE" Win_2.PaintPicture LoadPicture(Dst_Dir$ & OutputFile$), 0, 0
Do : Sleep : Until IsNothing(Me)
|
|
webu
Full Member
Posts: 149
|
Post by webu on Oct 10, 2023 15:34:48 GMT 1
With IrfanView i work since W95. That means more than a quarter century.
It is one of the most popular programs ever for Windows and extremely widespread. It is very small for the variety of what it can do.
I have therefore valued it for decades and often include it in my own programs. I have also always used it to save my own screens in any format.
|
|
|
Post by (X) on Oct 15, 2023 14:33:29 GMT 1
Side note:
|
|