| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
#31
|
|||
|
|||
|
on my server it is working perfectly. the problem occured on my local machine
|
|
#32
|
||||
|
||||
|
Quote:
|
|
#33
|
|||
|
|||
|
I would like to start off with by saying
GREAT CODE!!! OK. I have implemented you code into my Upload project But it only creates one image. Example The code for uploads, if the filename exist, then it add's a -# (# being 1 - 1000000 ) to the end of the image. I have added this to your script. Code:
Dim strImageName, strThumbName, objXML
strImageName = left(DestFileName, 255)
strThumbName = "th_"&left(DestFileName, 255)
Set objXML = Server.CreateObject("Microsoft.XMLHTTP")
objXML.Open "GET", "http://192.168.2.9/site/Projects/Images/ImageResizer.aspx?image=" & Server.MapPath(strImageName) & "&thumb=" & Server.MapPath(strThumbName) & "&width=144&height=218", True
objXML.Send
Set objXML=Nothing
But it will only save the image as: th_image.jpg So, if I upload 5 images with the same name, it will not create the Thumbnail past the first image name So if I do image-1.jpg (The upload script names it with a -1 as a duplicate) Your script will not create another image The Database Insertion works great, for every Thumbnail that is created, The Actual Thumbnail is never created. Also. how can I put the generated thumbnail into a specific folder? Without know the full drive path? Could you please assist me on this issue? Thank you. Carrzkiss [QUOTE=Shadow Wizard]Attached is aspx file that can resize given image on the fly to the desired width and/or height.QUOTE] |
|
#34
|
||||
|
||||
|
if the thumbnail is being saved with the same name, it means "DestFileName" has
the same value.. I'll need to see more code to be able to help with this. regarding saving in specific folder, it's more simple than what you think: Code:
objXML.Open "GET", "http://192.168.2.9/site/Projects/Images/ImageResizer.aspx?image=" & Server.MapPath(strImageName) & "&thumb=" & Server.MapPath("/thumbs/" & strThumbName) & "&width=144&height=218", True
see the bold part for what you need to change. |
|
#35
|
|||
|
|||
|
Hi!
this code is just what i need and it works beautifully on my localhost but on server its giving me the following error. Can you please suggest what i should do? thanking you in advance. Error saving file: A generic error occurred in GDI+. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Exception: Error saving file: A generic error occurred in GDI+. Source Error: Line 237: catch (Exception exp) Line 238: { Line 239: throw new Exception("Error saving file: "+exp.Message); Line 240: } Line 241: } Source File: d:\inetpub\vhosts\india\httpdocs\aspnetuploader\Im ageResizer.aspx Line: 239 Stack Trace: [Exception: Error saving file: A generic error occurred in GDI+.] ASP.BitmapWrapper.Save(String filename, ImageFormat fileFormat) in d:\inetpub\vhosts\india\httpdocs\aspnetuploader\Im ageResizer.aspx:239 ASP.BitmapWrapper.Save(String filename) in d:\inetpub\vhosts\india\httpdocs\aspnetuploader\Im ageResizer.aspx:228 ASP.aspnetuploader_imageresizer_aspx.Page_Load(Obj ect sender, EventArgs e) in d:\inetpub\vhosts\india\httpdocs\aspnetuploader\Im ageResizer.aspx:64 System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627 Quote:
|
|
#36
|
||||
|
||||
|
this is permissions problem.
http://weblogs.asp.net/anasghanem/a...-exception.aspx grant ASPNET account full permissions over the folder you're trying to create the thumbnail in and it should work fine. |
|
#37
|
|||
|
|||
|
Thankyou I got the code working
|
|
#38
|
|||
|
|||
|
Hi!
I am having some problem here. Please advised me. I had no problem with the codes on my own local machines. So prior the uploading to the server, i will have to change e URL. But however after that i had a problem. My image is uploaded but the image resizer never seemed to be executed. Please help! Basically while the files are resized it will be renamed as well. I need to execute Image Resizer twice to get 2 different sizes of the same image. Code:
IF objUpload("file1") <> "" THEN
Call objUpload.File(0).SaveToDisk(Server.MapPath("productimages"), varFileName1)
strImageName = "\productimages\" & varFileName1 & ""
strThumbName = "\productimages\stb_" & varFileName1 & ""
strDisplayName = "\productimages\sd_" & varFileName1 & ""
Set objXML = Server.CreateObject("Microsoft.XMLHTTP")
objXML.Open "GET", "http://www.abcefg.com/ImageResizer.aspx?image=" & Server.MapPath(strImageName) & "&thumb=" & Server.MapPath(strDisplayName) & "&width=328&height=-1", True
objXML.Send
Set objXML=Nothing
Set objXML = Server.CreateObject("Microsoft.XMLHTTP")
objXML.Open "GET", "http://www.abcefg.com/ImageResizer.aspx?image=" & Server.MapPath(strImageName) & "&thumb=" & Server.MapPath(strThumbName) & "&width=100&height=-1", True
objXML.Send
Set objXML=Nothing
END IF
|
|
#39
|
|||
|
|||
|
Secondly i faced another problem too:
I can execute these codes in IE7. However in Firefox, they said the image i upload is not an image. Can anyone please help? Thanks!! |
|
#40
|
||||
|
||||
|
Quote:
what do you mean "they said the image i upload is not an image"? who said? sounds like it's not related to the image resize code.. |
|
#41
|
|||
|
|||
|
shadwowizard, he is actually right! Its not JPG image file. Some image viewer cannot detect it as JPG if opened as JPG.
-------------------------------------------------------- I have found a major problem with this code. After resizing the image its mostly bigger than original. This increased my doubts about the image format itself. So I just tried to open new JPG image with IRFANVIEW Image Viewer, I was surprised to see that the JPG image was actually a PNG file. IRFANVIEW asked me to rename it to PNG as it detected it as PNG file. Then it opened it properly as PNG. Now the secret is revealed why the size was bigger. PNG is not a compressed format like intelligent compressed format like JPG. Now I came to know that the ASPX code is actually making PNG file and not the JPG though the extension we are asking it to make JPG. I am not into .NET, hence requresting the developer to make changes so it will not save JPG of 140kb into PNG of 400kb even after resizing to smaller size. I AM SURE THAT THE DRAWING NAMESPACE CAN HANDLE IT WELL TO MAKE A TRUE JPG IMAGE FILE, A COMMON PRACTICE IN INTERNET AUTHORING. Mahendra India |
|
#42
|
||||
|
||||
|
Quote:
|
|
#43
|
||||
|
||||
|
Proved to be one-line fix, I've uploaded the fix to my original post.
Problem was that I have used the "Raw Format" of the image object itself, which is probably PNG for some reason. Now I'm "forcing" JPEG image format and it appears to work fine. Thanks again! ![]() |
|
#44
|
|||
|
|||
|
Quote:
Dear Shadow Wizard! Simply WOW and THANKS. One more Suggestion and Request! The quality and size of JPEG image required by us, can be controlled while saving by level of quality adjustment e.g. 50% to 100%. Is there any parameter you can set in aspx file so that we can pass a value to control the quality and size of file even more accurate. Example for thumbnails the quality of 50% is enough which makes size 2 to 3 kbs only. For bigger size quality is around 65 to 75. Image still more clear but file size is optimum. Just give it a try. Lets make this code unbeatable. ------------------ Your reply was really so fast! I still wondor, how come no one noticed this problem in such a long duration of this code submission on 3rd October 2006? I feel great because I could give my bit to help you make this code outstanding. I will sure test it and post a feedback. Thanks a lot again. Mahendra Bhaarat (aka India) |
|
#45
|
|||||
|
|||||
|
Quote:
Your Wish Is My Command, see the original post I have uploaded new code that support different compression level for the thumbnail. To set desired compression, add "&compression=X" to the URL where X is the desired number. Let me know if you have problem with this. ![]() Quote:
Good question.. probably this code is not really in wide use or people just didn't care/notice. ![]() Quote:
No problem Mahendra, hope you'll put my code into good use! ![]() |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Image Resize Part II - resize image on the fly |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|