Notices

Great community. Great ideas.

Welcome to ASP/Free, a community dedicated to helping beginners and professionals alike in improving their knowledge of Microsoft's development and administration technologies. Sign up today to gain access to the combined insight of tens of thousands of members.

Thread: ShadowResizer - image resize on the fly (classic ASP)

Page 1 of 2 12 LastLast
Results 1 to 15 of 24
Share This Thread →
  1. #1
    Shadow Wizard's Avatar
    Shadow Wizard is offline Moderator From Beyond
    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,126
    Rep Power
    2921

    Post ShadowResizer - image resize on the fly (classic ASP)

    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.
    Attached Files Attached Files
    Last edited by Shadow Wizard; February 4th, 2007 at 01:23 AM.

  2. #2
    swremick is offline Registered User
    Join Date
    Apr 2006
    Posts
    1
    Rep Power
    0

    Exclamation Thanks, but need help!

    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. #3
    Shadow Wizard's Avatar
    Shadow Wizard is offline Moderator From Beyond
    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,126
    Rep Power
    2921
    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. #4
    chen is offline Contributing User
    Join Date
    Jul 2005
    Posts
    154
    Rep Power
    9
    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. #5
    Shadow Wizard's Avatar
    Shadow Wizard is offline Moderator From Beyond
    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,126
    Rep Power
    2921
    no idea what you mean, sorry.

  6. #6
    chen is offline Contributing User
    Join Date
    Jul 2005
    Posts
    154
    Rep Power
    9
    i mean is

    before the image is like this
    maybe this image is 190X20

    after i thumbnail the image it will become like this

    it become 128X128

    that mean is after i resize the image it not lose shape.
    hope you understand my question

    thanks

  7. #7
    Shadow Wizard's Avatar
    Shadow Wizard is offline Moderator From Beyond
    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,126
    Rep Power
    2921
    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. #8
    chen is offline Contributing User
    Join Date
    Jul 2005
    Posts
    154
    Rep Power
    9
    i also dun know how the Windows XP do it


  9. #9
    baseballdude_'s Avatar
    baseballdude_ is offline Expert Learner
    Join Date
    Feb 2005
    Location
    Wisconsin
    Posts
    1,909
    Rep Power
    97
    That's not the acutal image. The entire square is a placeholder, with an image inside it.

  10. #10
    chen is offline Contributing User
    Join Date
    Jul 2005
    Posts
    154
    Rep Power
    9
    Quote Originally Posted by baseballdude_
    That's not the acutal image. The entire square is a placeholder, with an image inside it.
    Yes, i want the thing like this

  11. #11
    baseballdude_'s Avatar
    baseballdude_ is offline Expert Learner
    Join Date
    Feb 2005
    Location
    Wisconsin
    Posts
    1,909
    Rep Power
    97
    Then just place a box around the image.

  12. #12
    chen is offline Contributing User
    Join Date
    Jul 2005
    Posts
    154
    Rep Power
    9
    Quote Originally Posted by baseballdude_
    Then just place a box around the image.
    yes i know.

    problem is how i resize the image and not lose the shape?

    Thanks

  13. #13
    Shadow Wizard's Avatar
    Shadow Wizard is offline Moderator From Beyond
    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,126
    Rep Power
    2921
    sorry chen, my program only resize the image. it's not meant for image preview.
    if you give it only width or height, it will perform "smart resize" and the
    image will not lose shape. I can't explain any better, hope you can
    understand.

  14. #14
    chen is offline Contributing User
    Join Date
    Jul 2005
    Posts
    154
    Rep Power
    9
    Quote Originally Posted by Shadow Wizard
    sorry chen, my program only resize the image. it's not meant for image preview.
    if you give it only width or height, it will perform "smart resize" and the
    image will not lose shape. I can't explain any better, hope you can
    understand.
    Ok never mind.

    because i have ask many people before how it do it.
    but poor is not one can answer me.

    And Thanks your code.

    Thanks Shadow Wizard and baseballdude_

  15. #15
    Shadow Wizard's Avatar
    Shadow Wizard is offline Moderator From Beyond
    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,126
    Rep Power
    2921
    no problem chen, sorry I can't help any further!

Page 1 of 2 12 LastLast
Share This Thread →

Become Part of This Conversation

Join NowFor Free!

Similar Threads

  1. javascript to resize background image to suit all screen reasalutions
    By sk8ter04 in forum HTML, JavaScript And CSS Help
    Replies: 4
    Last Post: November 6th, 2007, 02:21 AM
  2. vb: image resizing from stream to SQL Server
    By timandkids in forum .NET Development
    Replies: 0
    Last Post: November 10th, 2004, 11:54 AM
  3. Howto resize with stretch and save an image in jpg format?
    By zwonimir in forum Visual Basic Programming
    Replies: 3
    Last Post: August 24th, 2004, 06:08 AM
  4. resize external image.
    By telnoi in forum .NET Development
    Replies: 2
    Last Post: July 27th, 2004, 04:40 PM
  5. Image Resize Problem
    By adathelad in forum .NET Development
    Replies: 0
    Last Post: February 4th, 2004, 04:02 AM

ASP Free Advertisers and Affiliates