| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
note: newer version is available in this thread. I'm leaving this
thread to serve as different approach to the same issue. Attached is little C# command line application which can resize pictures using smart resize. Using the application requires .NET framework 1.1 or later to be installed on the computer. The application can be used with classic ASP too, with the WScript.Shell component - note that for this to work, you should have .NET framework installed on the server, plus permissions to execute command line applications. No installation is required - just copy the file to the same location as your ASP file and see the attached sample code for example of using it. sample picture is given as well. Sample code is below as well: Code:
--TestResize.asp
<% Option Explicit %>
<%
'-----------------------------------------
'constants
Const RESIZER_FILE_NAME="ShadowResizer.exe"
Const ORIGINAL_IMAGE_NAME="sample_picture.jpg"
Const THUMB_IMAGE_NAME="sample_picture_thumb.jpg"
'-----------------------------------------
'-----------------------------------------
'methods
Sub Resize()
Dim objShell, strCommand
Set objShell = Server.CreateObject("WScript.Shell")
strCommand = Server.MapPath(RESIZER_FILE_NAME) & " " & Server.MapPath(ORIGINAL_IMAGE_NAME)
If IsNumeric(Request("width")) Then
strCommand = strCommand & " -width=" & Request("width")
End If
If IsNumeric(Request("height")) Then
strCommand = strCommand & " -height=" & Request("height")
End If
strCommand = strCommand & " -saveas=" & Server.MapPath(THUMB_IMAGE_NAME)
objShell.Run strCommand, 0, True
Set objShell=Nothing
End Sub
'-----------------------------------------
'-----------------------------------------
'main
If Request("action")="1" Then
Call Resize()
End If
'-----------------------------------------
%>
<html>
<head>
<title>Shadow Resizer Example</title>
</head>
<body>
Original image: <img src="<%=ORIGINAL_IMAGE_NAME%>" /><br />
<% If Request("action")="1" Then %>
New image: <img src="<%=THUMB_IMAGE_NAME%>" /><br />
<% End If %>
<form action="<%=Request.ServerVariables("Script_Name")%>">
<input type="hidden" name="action" value="1" />
Width: <input type="text" name="width" value="<%=Request("width")%>" />(empty to smart resize by height)<br />
Height: <input type="text" name="height" value="<%=Request("height")%>" />(empty to smart resize by width)<br />
<button type="submit">Resize</button>
</form>
</body>
</html>
as you can see, the sample page take picture and let you decide its new height and/or width - the resulting picture is true thumbnail with new dimensions. Last edited by Shadow Wizard : February 4th, 2007 at 01:23 AM. |
|
#2
|
|||
|
|||
|
Hi Shadow, thanks for the great code. I seem to recieve an error from the exe file. I have it installed on my locall IIS machine, and I think I have execute rights on the folder it is in. Maybe I have granted incorrect permissions?
Here is the error, it occurs after I enter demension and I cick resize: Application has generated an exception that could not be handled. Process id=0x678 (1656), Thread id=0x15cc (5580). Any ideas on what the problem could be? I do have .Net Framework installed on my machine. Thanks |
|
#3
|
||||
|
||||
|
sounds like you don't have the .NET framework, or maybe you have old version.
if you do have the new version, try executing the application from the command line: Start --> Run --> Cmd --> cd C:\Inetpub\wwwroot --> ShadowResizer.exe ... and hopefully more meaningful error message will appear in the console. |
|
#4
|
|||
|
|||
|
its very good.
but can it do like in windows Thumbnails function? i means is in My Pictures Folder Function. somethings like this before [img] http://img.photobucket.com/albums/v430/Chen/new.gif [/img] after [img] http://img.photobucket.com/albums/v430/Chen/newthumd.gif [/img] Thanks. |
|
#5
|
||||
|
||||
|
no idea what you mean, sorry.
|
|
#6
|
|||
|
|||
|
i mean is
before the image is like this maybe this image is 190X20after i thumbnail the image it will become like this it become 128X128that mean is after i resize the image it not lose shape. hope you understand my question thanks |
|
#7
|
||||
|
||||
|
if you force both width and height, it would "lose shape". nothing can fix that.
this image you posted is the same image, only in the second you put white background around it. I have no clue what you did by that. |
|
#8
|
|||
|
|||
|
i also dun know how the Windows XP do it
![]() |
|
#9
|
||||
|
||||
|
That's not the acutal image. The entire square is a placeholder, with an image inside it.
__________________
www.xoise.com - www.ourfreegames.com - www.playtouchgames.com - www.randomtools.net - www.xenocide-rpg.com |
|
#10
|
|||
|
|||
|
Quote:
Yes, i want the thing like this ![]() |
|
#11
|
||||
|
||||
|
Then just place a box around the image.
|
|
#12
|
|||
|
|||
|
Quote:
yes i know. problem is how i resize the image and not lose the shape? Thanks |
|
#13
|
||||
|