Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Mod: Resizing Images on Upload
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Mod: Resizing Images on Upload

 Post Reply Post Reply Page  123>
Author
 Rating: Topic Rating: 2 Votes, Average 5.00  Topic Search Topic Search  Topic Options Topic Options
TonyM View Drop Down
Newbie
Newbie
Avatar

Joined: 10 November 2009
Location: Downunder
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote TonyM Quote  Post ReplyReply Direct Link To This Post Topic: Mod: Resizing Images on Upload
    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: 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!






Edited by TonyM - 14 November 2009 at 7:19am
Back to Top
madpakke View Drop Down
Groupie
Groupie


Joined: 09 June 2009
Status: Offline
Points: 165
Post Options Post Options   Thanks (0) Thanks(0)   Quote madpakke Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
123Simples View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 July 2007
Location: United Kingdom
Status: Offline
Points: 1192
Post Options Post Options   Thanks (0) Thanks(0)   Quote 123Simples Quote  Post ReplyReply Direct Link To This Post Posted: 29 March 2010 at 2:48pm
Quote 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
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post Posted: 30 March 2010 at 9:27am
Actually, TWS, thats incorrect.

Quote ASPupload and ASPjPeg need to be installed on your WebServer (they are installed by default on Web Wizing)
 Wink

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.

This page may help in replacing the respective properties from ASPJpeg to ASPImage.


Edited by Scotty32 - 30 March 2010 at 9:32am
S2H.co.uk - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
TonyM View Drop Down
Newbie
Newbie
Avatar

Joined: 10 November 2009
Location: Downunder
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote TonyM Quote  Post ReplyReply Direct Link To This Post 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.




Back to Top
123Simples View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 July 2007
Location: United Kingdom
Status: Offline
Points: 1192
Post Options Post Options   Thanks (0) Thanks(0)   Quote 123Simples Quote  Post ReplyReply Direct Link To This Post Posted: 30 March 2010 at 12:48pm
Originally posted by Scotty32 Scotty32 wrote:

Actually, TWS, thats incorrect.

Quote ASPupload and ASPjPeg need to be installed on your WebServer (they are installed by default on Web Wizing)
 Wink

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.

This page may help in replacing the respective properties from ASPJpeg to ASPImage.


Thanks Scotty Smile
My mistake there madpakkle
Back to Top
madpakke View Drop Down
Groupie
Groupie


Joined: 09 June 2009
Status: Offline
Points: 165
Post Options Post Options   Thanks (0) Thanks(0)   Quote madpakke Quote  Post ReplyReply Direct Link To This Post 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..
 
Back to Top
TonyM View Drop Down
Newbie
Newbie
Avatar

Joined: 10 November 2009
Location: Downunder
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote TonyM Quote  Post ReplyReply Direct Link To This Post Posted: 22 April 2010 at 10:38am
Hi MadPakke

Shot you a PM


Back to Top
 Post Reply Post Reply Page  123>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.