PDA

View Full Version : Can Resizer run with no interface?



Hercules Gunter
03-04-2014, 01:43 AM
I am wanting to use Light Image Resizer on a Web server, in a process called from a script. I have successfully submitted a Shell command to run the resizing operation I want, with a command line with the following parameters - tokens bounded by %...% have values substituted at run time. What I'm wanting to do is reduce images to a maximum dimension of 1000 pixels in either dimension.

"%binFolder%\resize.exe" "%SourceImage%"
/h=1000
/w=1000
/dest="%DestinationPath%"
/Policy=reduce
/Action=move
/Minimized
/autoclose
/conflict=overwrite
/run

If I run the generated command manually on the server, it works perfectly and the image is successfully resized and moved to the target location.

When the command is run by the Web app, resizer.exe starts up and then sits there until terminated using Task Manager. I suspect that the process is trying to open up a window and, since it's running in the IIS context, cannot do so.

Is it possible to run the program as a scripted action in a non-interactive mode?

Hercules Gunter




You can use Light Image Resizer as a command line, so you can call it from anything like a batch script, .net , c# , csharp, cgi , visual basic or delphi

Feel free to ask any question about licensing or suggest any addition.
Basically you can find also all the options of Light Image Resizer in the registry, so you can easily program it the way you need it for your project.

Image Resizer Command Line Switches
===================================
{snipped}

Phil
03-04-2014, 04:14 PM
Please try if it's any different with this version:
http://download2.obviousidea.com/light_image_resizer4_setup_4.5.9.0.exe

Also, try unchecking "Multithread processing" in Settings -> Processing.

EDIT: Just came to my mind: Is the destination path guaranteed to exist? If not, there will be a user prompt, which could be causing the issue.

Hercules Gunter
03-05-2014, 04:43 AM
I installed the version you suggested, and disabled multithread processing. The result is that the process still hangs.

The destination folder definitely does exist for my test case. In the general case, it ought to exist if we set things up correctly.

To make things absolutely clear, the installation of resize.exe is to c:\Program Files (x86). For simplicity when running the Web update, I have set up a bin folder in the Web site root folder and placed a copy of resize.exe in that. The generated command calls this version. As stated, it works perfectly if the command is run in a command window. When run in a Shelled process, it hangs (until the process is terminated manually). [If one executes the Shell command in synchronous mode, it hangs; if run asynchronously, the process hangs but the calling process proceeds blithely on, making the assumption that it worked.]

I wrote my own very simplistic version of a resizer, and when I tried to make a DLL of it I found that the routines it called to do the resizing are available only if one has an interface, i.e. it depends on the system-supplied canvas object which is available only if a display screen of some sort exists. I was hoping that you might have achieved the resizing some other way than using the MS-supplied System.Drawing objects built into Windows.

I'm coming to the conclusion that you are using those components, and that therefore what I'm hoping for can't happen with your program. Is this too pessimistic an assessment?

Phil
03-05-2014, 03:33 PM
After a few tests, I think the problem might be with the account (IIS?) under which Light Image Resizer is launched.

I'm going to check if there's a workable solution...

Phil
03-06-2014, 02:00 PM
Please try this version (zip contains just the binary):
http://download2.obviousidea.com/hidden/Resize_4.5.9.2.zip

Before using it from the web app, make sure to add your license key for all users as follows:


Key: HKEY_LOCAL_MACHINE\SOFTWARE\ObviousIdea\ImageResiz er\4.0
Name: LicenseKey
Value: <Your key>

Hercules Gunter
03-10-2014, 11:11 PM
Worked like a charm - well done, and thank you.

==========

Please try this version (zip contains just the binary):
http://download2.obviousidea.com/hidden/Resize_4.5.9.2.zip

Before using it from the web app, make sure to add your license key for all users as follows:


Key: HKEY_LOCAL_MACHINE\SOFTWARE\ObviousIdea\ImageResiz er\4.0
Name: LicenseKey
Value: <Your key>

Hercules Gunter
03-10-2014, 11:31 PM
Oops - I forgot that I had sidestepped the resize call in my code. I've reinstated the call, and the program no longer hangs. The Web app continues happily in the belief that all has gone well, but unfortunately the resized image does not appear in the target location, and the unresized image remains in the source location.

I've reproduced the generated command below. Note that Action=move, so the source image should be deleted. As noted above, it remains there. When I execute the command given below in a Command box, the result is that the source image disappears and in the target folder is the file Exp1000121 [Desktop Resolution].jpg, reduced from 1.8 MB to 108 KB, which is the desired result. The extension to the name is not welcome, but could be worked around by renaming the folder.

We have progress! It no longer hangs, but on the other hand it doesn't actually do anything.

"C:\Users\Public\Dev Resources\TimePro App\TPHerc\bin\resize.exe" "C:\Users\Public\Dev Resources\TimePro App\TPHerc\TP55\User\TP55_\ExportData\Exp1000121.j pg" /h=1000 /w=1000 /dest="C:\Users\Public\Dev Resources\TimePro App\TPHerc\TP55\User\TP55_\Documents\" /Policy=reduce /Action=move /Minimized /autoclose /conflict=overwrite /run


======

Please try this version (zip contains just the binary):
http://download2.obviousidea.com/hidden/Resize_4.5.9.2.zip

Before using it from the web app, make sure to add your license key for all users as follows:


Key: HKEY_LOCAL_MACHINE\SOFTWARE\ObviousIdea\ImageResiz er\4.0
Name: LicenseKey
Value: <Your key>

Phil
03-11-2014, 03:24 PM
Ok, please locate the log file and post it here. ImageResizer.log should be in %appdata%\ObviousIdea, so usually
C:\Users\<username>\AppData\Roaming\ObviousIdea
<username> will be the account your web app is running under, of course.

In case it's running in the SYSTEM account, the log will be in:

32-bit Windows:
C:\Windows\System32\config\systemprofile\AppData\R oaming\ObviousIdea
64-bit Windows:
C:\Windows\SysWOW64\config\systemprofile\AppData\R oaming\ObviousIdea

Hercules Gunter
03-12-2014, 02:37 AM
I have attempted to attach ImageResizer_log.zip. The text itself was too large at 36KB.

Phil
03-12-2014, 10:15 AM
I only see two successful sessions with 4.5.9.2, so I assume this is the log from your account where you tested via command prompt, not the IIS one.

To make sure we get the correct log, I have added a value to override the log file path in this new version:
http://download2.obviousidea.com/hidden/Resize_4.5.9.3.zip

Please create a registry value like this:


Key: HKEY_LOCAL_MACHINE\SOFTWARE\ObviousIdea\ImageResiz er\4.0
Name: LogPath
Value: C:\Users\Public\Dev Resources\TimePro App\TPHerc\TP55\User\

You can specify any path the IIS account can write to.

Please try again and collect any log created in this path.
If the application crashes for instance, the log will be named something like ImageResizer_crash_PID1234.log, where 1234 is the process ID.

The new version should also fix the filename mask problem, and not rename the file anymore.

Hercules Gunter
03-16-2014, 04:01 AM
I'm sorry to report that there is no difference in behaviour. When the program hangs, there is no entry added to the log file. The attached log file has entries corresponding to invoking the program manually, and a failure in my calling code, and finally a manual run of the generated command.

When I run the command in a command box, the program pops up an interface very briefly, and all goes as planned. When it's run by IIS, it simply hangs, presumably because of the attempt to open the interface. I have the notion that that interface is required when trying to run the image-handling routines using the Windows graphics code, and when run with the Shell command it is not permitted.

Anyway, over to you again. Please feel free to write to my email address if that will make for speedier communication. thank you for all your trouble on my behalf!