#16
  1. No Profile Picture
    Contributing User
    ASP Explorer (0 - 99 posts)

    Join Date
    Aug 2007
    Location
    Pennsylvania
    Posts
    43
    Rep Power
    9
    Originally Posted by Shadow Wizard
    Attached is aspx file that can resize given image on the fly to the desired width and/or height.

    To use this in classic ASP code, use XMLHTTP component in
    order to "communicate" with the aspx file. simply pass the
    URL as demonstrated above:
    Code:
    <%
    Dim strImageName, strThumbName, objXML
    strImageName = "mypicture.jpg"
    strThumbName = "mypicture_thumb.jpg"
    Set objXML = Server.CreateObject("Microsoft.XMLHTTP")
    objXML.Open "GET", "http://localhost/ImageResizer.aspx?image=" & Server.MapPath(strImageName) & "&thumb=" & Server.MapPath(strThumbName) & "&width=500&height=-1", True
    objXML.Send
    Set objXML=Nothing
    Response.Write("original: <img src=""" & strImageName & """ /><br />")
    Response.Write("thumbnail: <img src=""" & strThumbName & """ /><br />")
    %>
    Shadow Wizard,
    I am a noob at this... so I just want to be sure that I am understanding how to accomplish this. I have your original code ShadowUploader.asp. However, I was wondering how the ImageResizer.aspx correlates to the ShadowUploader.asp. In other words, is the ImageResizer working in conjunction with the ShadowUploader? If so, I am assuming that I will need to use a file include on either my upload form or the actual ShadowUploader page?

    Second, I am not clear on your above instructions of the ImageResizer. When you say to the pass the URL, am I to just type in the URL to the browser window? I am using IIS on my local computer for testing purposes. Thank you in advance... I have never created a photo upload before so I am kind of in the dark.
  2. #17
  3. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2921
    right now, the Image Resize and Upload are not related in any way.
    I can add some built in integration, just need some time for this.

    you need to use XMLHTTP component in order to call and use the
    Resizer from within classic ASP code, the first post in the thread
    contains full source code needed for that. (last block of code)
  4. #18
  5. No Profile Picture
    Contributing User
    ASP Explorer (0 - 99 posts)

    Join Date
    Aug 2007
    Location
    Pennsylvania
    Posts
    43
    Rep Power
    9
    Thanks Shadow Wizard. I will now dip my pinky toe into the dark and foreign waters of photo upload. )
  6. #19
  7. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Nov 2007
    Posts
    14
    Rep Power
    0
    Hi Shadow Wizard,

    First of all thank you for sharing the script with all of us.

    I am actually putting together a image cropper feature and there it will allow a user to scale the image as well as select an area to crop. Base on your script is it possible to pass the additional information like the x & y coords and the scaled factor to your script to process and create thumbnail accordingly? If yes, how do i go about doing so?

    Thanks...
  8. #20
  9. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2921
    yes you can pass additional values over the querystring, for example:
    Code:
    objXML.Open "GET", "http://localhost/ImageResizer.aspx?image=" & Server.MapPath(strImageName) & "&thumb=" & Server.MapPath(strThumbName) & "&x1=50&y1=100&x2=150&y2=200", True
    this will pass two points: (x1,y1) and (x2,y2) of area to be cropped.
    however, the cropping itself will need whole different code than what I have.
  10. #21
  11. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Nov 2007
    Posts
    14
    Rep Power
    0
    Would it be hard to modify the script to include cropping and is it easy? Or maybe you could point me to the right direction where i can get more info on this and i try it out myself to see if it works. I'm up for the challenge

    Thanks also for the prompt reply.
  12. #22
  13. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2921
    I found this, which look pretty nice:
    http://snippets.dzone.com/posts/show/1484
  14. #23
  15. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Nov 2007
    Posts
    14
    Rep Power
    0
    Thank you for the URL Shadow. Will give it a try in the morning. Will post my results here if it works. Thanks again.
  16. #24
  17. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2921
    if it works you can post here the whole modified code for the benefit of others.
  18. #25
  19. No Profile Picture
    Contributing User
    ASP Explorer (0 - 99 posts)

    Join Date
    Mar 2007
    Posts
    68
    Rep Power
    8
    very nice code

    thanks
  20. #26
  21. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Apr 2008
    Posts
    1
    Rep Power
    0

    Realtime resize without saving image on the server?


    ImageResizer.aspx is one cool script!

    Now for the impossible feature: Would it be possible for ImageResizer.aspx to return the resized image?

    To be used like this:
    <img src="ImageResizer.aspx?image=test.jpg">

    To show the small image realtime, without saving it on the server.

    Found a way!!!! (Still needs a bit of work..)
    Edited ImageResizer.aspx, commented lines listed below and added a few lines.
    .
    .
    .
    //string strThumbnailPath=ToStringDef
    .
    .
    .
    //if (strThumbnailPath.Length == 0)
    //{
    // Response.Write("missing thumbnail path");
    // Response.End();
    //}
    .
    .
    .
    //wrapper.Save(strThumbnailPath);
    Response.Buffer = true; //New
    Response.ContentType = "image/jpeg"; //New
    wrapper.Bitmap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); //New
    bitmap.Dispose();
    //Response.Write("OK");
    .
    .
    .

    ASP call is like this:
    <img src="ImageResizer.aspx?image=C:\WebSites\ImageTest ing\test2.jpg&width=200&height=-1" />

    Comments on this post

    • Shadow Wizard agrees
  22. #27
  23. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Nov 2007
    Posts
    14
    Rep Power
    0
    My apologies my fellow coders...

    i realised that i never updated this thread. I never did get to fixing the code as we took a short cut to solve the image cropping and resize problem. As our server supported php running parallel with asp we found a third party code running in php that uses GD to manipulate the image. What we did was a popup loading the php file to manipulate the image, save it to our target location then got php to talk to asp (php talk to asp?? oh yes it is possiblle.) informing that it was done and to update our database. I know i have sidelined from asp but as a programmer we have to resourceful to get the problem solved. lolz..
  24. #28
  25. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2921
    Originally Posted by dsflores
    ImageResizer.aspx is one cool script!

    Now for the impossible feature: Would it be possible for ImageResizer.aspx to return the resized image?
    ...
    ASP call is like this:
    <img src="ImageResizer.aspx?image=C:\WebSites\ImageTest ing\test2.jpg&width=200&height=-1" />
    thanks for sharing this - cool trick, cheers for finding it!

    @saturnx - no worry, that's fine. thanks for letting us know.
  26. #29
  27. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2009
    Posts
    2
    Rep Power
    0
    hello i need help. i try to use your script and i'm keep geting an error:

    this is with code with your debug code:

    URL: http://localhost/test_page/ImageResizer.aspx?image=test.jpg&thumb=test_thumb. jpg&width=120&height=-1

    msxml3.dll error '8000000a'

    The data necessary to complete this operation is not yet available.

    Originally Posted by Shadow Wizard
    thanks for sharing this - cool trick, cheers for finding it!

    @saturnx - no worry, that's fine. thanks for letting us know.
  28. #30
  29. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2921
    Originally Posted by ranegade
    hello i need help. i try to use your script and i'm keep geting an error:

    this is with code with your debug code:

    URL: http://localhost/test_page/ImageResizer.aspx?image=test.jpg&thumb=test_thumb. jpg&width=120&height=-1

    msxml3.dll error '8000000a'

    The data necessary to complete this operation is not yet available.
    sounds like problem with the XMLHTTP component on the server..
    are you hosted?

Similar Threads

  1. ShadowResizer - image resize on the fly (classic ASP)
    By Shadow Wizard in forum Code Bank
    Replies: 23
    Last Post: June 26th, 2011, 01:51 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

IMN logo majestic logo threadwatch logo seochat tools logo