Mod: Resizing Images on Upload
Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums Modifications
Forum Description: Mod's and Add-on's for Web Wiz Forums.
URL: https://forums.webwiz.net/forum_posts.asp?TID=28018
Printed Date: 28 March 2026 at 9:03am Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: Mod: Resizing Images on Upload
Posted By: TonyM
Subject: Mod: Resizing Images on Upload
Date Posted: 12 November 2009 at 7:41am
I had a play today and put together this mod to downsize images uploaded whilst posting a topic or uploaded via FileManager.
Resize Images on upload Mod Version: 0.9 WWF Version: 9.63 Mod Download: http://www.LureLovers.com/WWF_Mods/Functions_Upload.zip" rel="nofollow - Download Zipped Functions_Upload.asp Here Mod Author: TonyM Release Date: 12th Nov 2009 Updated: N/A
Installation: Download and extract the Functions_Upload.asp file to the Functions subdirectory of your forum (Backup/Rename the old file first so you can revert to it later if you wish)
That's it!
Alternatively edit the file yourself using the code example below
Requirements: ASPupload and ASPjPeg need to be installed on your WebServer (they are installed by default on Web Wizing)
Overview:
Basically if an image is larger than 640 pixels in width I resize it to 640 and maintain the current aspect ratio. All tested files uploaded end up significantly smaller (including those smaller than 640px wide) which is great for saving space and bandwidth.
I also changed the max image upload in forum settings to 2mb as the files are resized upon upload, although you can obviously set that to whatever you like.
In \functions\functions_upload.asp after this code (approx line 170)
'Get the file name strNewFileName = .Files(1).ExtractFileName]
|
I inserted this code
If strUploadType = "image" Then 'Dimension variables Dim Jpeg
' Create instance of AspJpeg Set Jpeg = Server.CreateObject("Persits.Jpeg")
'maintain aspect ratio Jpeg.PreserveAspectRatio = True ' Open source image Jpeg.Open .Files(1).path
'shrink if it's greater than 640px wide so it fits nicely on pages If Jpeg.OriginalWidth > 640 Then Jpeg.Width = 640 End If ' Save resized image to disk Jpeg.Save .Files(1).path End If
|
I hope it's of use to someone, I noticed a few other people were asking for this when I was looking to see if it had been done to save me doing it!
If you use it please let me know how you go!
------------- Cheers,
Tony
|
Replies:
Posted By: madpakke
Date Posted: 29 March 2010 at 6:41am
TonyM: Is it possible to make a version af resizing code, so it works with these Components: AspUpload3.0.0.3 AspSmartUpload 3.x AspImage 2.x W3 Jmail4.4 MyODBC-3.51.12 ODBC.NET
Because these is the only components ive got on my webhost.
|
Posted By: 123Simples
Date Posted: 29 March 2010 at 2:48pm
ASPupload and ASPjPeg need to be installed on your WebServer (they are
installed by default on Web Wizing) |
I think you will find that the components are within your requirements madpakke, but always make a backup first of any files you intend to change
------------- http://www.123simples.com/" rel="nofollow - Visit 123 Simples Web Design
|
Posted By: Scotty32
Date Posted: 30 March 2010 at 9:27am
|
Actually, TWS, thats incorrect.
ASPupload and ASPjPeg need to be installed on your WebServer (they are installed by default on Web Wizing) | 
Madpakke listed the components his server has, and it did not include ASPJpeg.
ASPUpload will only upload the image (hence the name) it will not resize it, you need an Image Editing component for that (ie ASPJpeg).
Most of the ones he listed are irrelevant, but the one hes looking for is ASPImage, to replace ASPJpeg. The problem is, the code that TonyM has written will only work with ASPJpeg, so Madpakke is asking for it to be altered to work with ASPImage.
http://www.serverobjects.com/comp/Aspimage.htm" rel="nofollow - This page may help in replacing the respective properties from ASPJpeg to ASPImage.
------------- S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins
For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .
|
Posted By: TonyM
Date Posted: 30 March 2010 at 9:56am
Hi Madpakke,
I'm more than happy to have a look at it when I've got a bit of spare time.
I'm not familiar with ASPimage although I had a quick look at the link Scotty32 kindly provided and it looks like it will have the functionality required.
------------- Cheers,
Tony
|
Posted By: 123Simples
Date Posted: 30 March 2010 at 12:48pm
Scotty32 wrote:
Actually, TWS, thats incorrect.
ASPupload and ASPjPeg need to be installed on your WebServer (they are installed by default on Web Wizing) | 
Madpakke listed the components his server has, and it did not include ASPJpeg.
ASPUpload will only upload the image (hence the name) it will not resize it, you need an Image Editing component for that (ie ASPJpeg).
Most of the ones he listed are irrelevant, but the one hes looking for is ASPImage, to replace ASPJpeg. The problem is, the code that TonyM has written will only work with ASPJpeg, so Madpakke is asking for it to be altered to work with ASPImage.
http://www.serverobjects.com/comp/Aspimage.htm" rel="nofollow - This page may help in replacing the respective properties from ASPJpeg to ASPImage.
|
Thanks Scotty  My mistake there madpakkle
------------- http://www.123simples.com/" rel="nofollow - Visit 123 Simples Web Design
|
Posted By: madpakke
Date Posted: 22 April 2010 at 9:58am
|
TonyM you got a pm now..
I´m willing to pay for a working Resizing script on my webhost, because its a big problem fore me, that pictures dosen´t get smaller..
|
Posted By: TonyM
Date Posted: 22 April 2010 at 10:38am
Hi MadPakke
Shot you a PM
------------- Cheers,
Tony
|
Posted By: MadDog
Date Posted: 24 April 2010 at 3:00am
If you need a paid mod feel free to send me a PM. I know WWf inside and out.
------------- http://www.iportalx.net" rel="nofollow">
|
Posted By: billd3
Date Posted: 05 May 2010 at 4:35pm
2 or 3 questions on this script (great idea, by the way)
1. Can I assume that since we host with Bruce and company here, this will work with our forum?
2. I see I can edit the number so if we wish, say, 800 instead of 640 that's pretty simple, however, what about those who upload files to use in their SIGNATURE......... is it possible to let 640 be the default, but choose a smaller size for signature photos, etc.? Or is that a non-issue?
I can't recall which upload process is used, but Bruce is the host, his package, server, etc so I believe it's got everything needed..........
------------- BillD
http://theamcpages.com
http://theamcforum.com
|
Posted By: madpakke
Date Posted: 07 May 2010 at 8:17am
|
Tonym>>> Do you got a test forum where we can see the resizeing script in action.?
|
Posted By: pbanks
Date Posted: 11 May 2010 at 1:02am
This is a really great MOD that makes life so much easier for our image "challenged" uploaders. Works like a treat and keeps my users happy (and me, not having to deal with resizing requests) ...
|
Posted By: TonyM
Date Posted: 11 May 2010 at 11:23pm
@ billd3 1 - Yes 2 - If images uploaded have a width less than the value you have set in the script they are not resized.
@ madpakke - No I do not have a public test server (only my private offline one) I use this script on my own live forum at www.lurelovers.com
@ pbanks - Thanks, I have a few "image challenged" users on my own forum, and this has saved me a huge amount of time (plus encouraged members to participate who otherwise would not have) 
------------- Cheers,
Tony
|
Posted By: billd3
Date Posted: 17 May 2010 at 3:07pm
I downloaded the file, compared it to the file we have been using, the ONLY difference was the resize part. So I simply uploaded the file as it sits, no mods. I then tried an image that was known to bee too large.... Instead of an upload and resize, I got an error stating the image was too large..... it is 400K and we're limited to 200K. So sort of defeats the purpose, eh? The image has to be already small enough in order for it to work, OR did I miss something??
------------- BillD
http://theamcpages.com
http://theamcforum.com
|
Posted By: TonyM
Date Posted: 18 May 2010 at 12:00am
billd3 wrote:
I downloaded the file, compared it to the file we have been using, the ONLY difference was the resize part. So I simply uploaded the file as it sits, no mods. I then tried an image that was known to bee too large.... Instead of an upload and resize, I got an error stating the image was too large..... it is 400K and we're limited to 200K. So sort of defeats the purpose, eh? The image has to be already small enough in order for it to work, OR did I miss something??
|
G'Day Bill
This would be the bit that you missed 
"I also changed the max image upload in forum settings to 2mb as the
files are resized upon upload, although you can obviously set that to
whatever you like."
------------- Cheers,
Tony
|
Posted By: billd3
Date Posted: 18 May 2010 at 12:47pm
OK, Tony, here in the states, we have the expression "DUH" I think it's appropriate that I use that now......... DUH! Of course, that rule would block any upload before the script could work. I'll give that a shot. Being that new cameras often create files that are 2.5 meg in size or so (at least mine does) I'll have to raise it a bit. Thanks ;-)
------------- BillD
http://theamcpages.com
http://theamcforum.com
|
Posted By: andyb323
Date Posted: 29 May 2010 at 4:17am
|
This mod does not work on my board.. I have uploaded the Asp, and when i try to upload any Photo i get the error that it can't upload Error 500 i think
I am using version 9.68
|
Posted By: klr3
Date Posted: 23 June 2010 at 8:44pm
|
This is SOOO cool!
If you want to get even smaller image sizes, just ad the quality-parameter from 0-100, where 100 is the best quality. I recommend 75:
'maintain aspect ratio Jpeg.PreserveAspectRatio = True
Jpeg.Quality = 75
|
|
Posted By: hohuybinh
Date Posted: 30 July 2010 at 6:38am
If you want to resize. you should to ensure image isn't break. I'm prevent image file size 18-20kb If the user's avatar is too large you can use div tag to contain it.
|
|