Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Auto Resize Image Attachments (Avatars & Profile Pic Too).... Details »»
Auto Resize Image Attachments (Avatars & Profile Pic Too)....
Version: 1.00, by mini2 mini2 is offline
Developer Last Online: Oct 2010 Show Printable Version Email this Page

Version: 3.0.6 Rating:
Released: 08-16-2004 Last Update: 11-11-2004 Installs: 73
 
No support by the author.

Gone

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #32  
Old 12-31-2004, 05:07 PM
MajorFm.com MajorFm.com is offline
 
Join Date: Dec 2004
Location: UK
Posts: 402
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice hack... thanks...
Reply With Quote
  #33  
Old 12-31-2004, 07:16 PM
KTBleeding's Avatar
KTBleeding KTBleeding is offline
 
Join Date: Feb 2004
Location: Tooele, UT
Posts: 756
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have been looking for this hack..

[high]* KTBleeding will install when he gets off work.
[/high]

EDIT:

Installed and working fine! I'm so glad I found this hack.
[high]* KTBleeding clicks install[/high]
Reply With Quote
  #34  
Old 01-07-2005, 02:10 PM
MajorFm.com MajorFm.com is offline
 
Join Date: Dec 2004
Location: UK
Posts: 402
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Im getting a error on uploading a avatar thats bigger then the dimentions set...

Fatal error: Call to undefined function: remote_filesize() in /usr/local/apache/www/crazyapes/majorfmforum.com/htdocs/forum/includes/functions_upload.php on line 106
Reply With Quote
  #35  
Old 01-23-2005, 06:38 PM
magyosha magyosha is offline
 
Join Date: Sep 2003
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

could not get this working at all
always says the image is to large and makes no attempt to resize ..
checked and double checked all the editing that was needed ... (tryed with profiles & atachments)
running vb 3.0.3 with the latest security fix's applied

attachments stored in the filesystem .. but would not think this would affect the profile pic as they are in the dbase .. and they don't work either ..
Reply With Quote
  #36  
Old 01-26-2005, 06:34 PM
kall's Avatar
kall kall is offline
 
Join Date: Apr 2004
Location: New Zealand
Posts: 2,608
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Parse error: parse error, unexpected T_ELSE in /home3/nzboards/public_html/forums/includes/functions_upload.php on line 341

That's just trying to upload a gif larger than the dimensions. Same thing happens if I use jpg.
Reply With Quote
  #37  
Old 01-26-2005, 09:43 PM
kall's Avatar
kall kall is offline
 
Join Date: Apr 2004
Location: New Zealand
Posts: 2,608
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by mini2
Possibly a typo? Could you post that line and I can compare?
Line 341:

PHP Code:
else 


Context - lines 321 to 362
PHP Code:
        if ($imginfo[2] != AND $imginfo[2] != AND $imginfo[2] != 3)
        { 
// .gif, .jpg, .png
            
if ($showerrors)
            {
                @
unlink($filename);
                if (
$incp)
                {
                    
print_stop_message('the_uploaded_file_is_not_valid');
                }
                else
                {
                    eval(
print_standard_error('error_imagenotimage'));
                }
            }
            else
            {
                return 
false;
            }
        }
    }
    else
    {
        if (!
$vboptions['allowimgsizefailure'])
        {
            if (
$showerrors)
            {
                @
unlink($filename);
                if (
$incp)
                {
                    
print_stop_message('the_uploaded_file_is_not_valid');
                }
                else
                {
                    eval(
print_standard_error('error_imagenotimage'));
                }
            }
            else
            {
                return 
false;
            }
        }
    } 
Reply With Quote
  #38  
Old 02-06-2005, 05:10 PM
givemeplain givemeplain is offline
 
Join Date: Dec 2004
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey, this works well for me .. but is there a way so that when an image is reduced in size, you can click on it (in post) to view it full size in a new window or something? Thanks.
Reply With Quote
  #39  
Old 02-23-2005, 07:22 PM
MrNase MrNase is offline
 
Join Date: May 2003
Location: Germany
Posts: 670
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by mini2
As an update I've completely removed this hack, thenreinstalled itusing the current uploaded files and it worked with 100%success foravatars and attachments. I tested large jpg, png and gifimagesfor the attachments, no errors, no problems. That's withvBulletin3.0.6.
Thank you very much. I updated because some members reported errors which I never got. I really hope these are resolved now
Reply With Quote
  #40  
Old 02-28-2005, 07:42 PM
John_44 John_44 is offline
 
Join Date: Aug 2004
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Very nice Hack !
Unfortunatly it doesn´t work for me. No errors until i upload a larger Image -> Then it says Error 500 -> could not execute Script. I´m using the German Provider 1&1 and would apreciate every help possible.

(GD Lib is installed)
Reply With Quote
  #41  
Old 03-08-2005, 08:28 PM
John_44 John_44 is offline
 
Join Date: Aug 2004
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, it always hapens.
Reply With Quote
  #42  
Old 03-10-2005, 02:39 PM
John_44 John_44 is offline
 
Join Date: Aug 2004
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, i played around with it. Please notice that i know nothing about PHP, but i was able to track down the Problem:

If i change:

if ($width_factor > $height_factor)
{
$nw = round($w / $width_factor);
$nh = round($h / $width_factor);
}

to:

if ($width_factor > $height_factor)
{
$nw = 400 ;
$nh = round($h / $width_factor);
}

it works. 500,600,1000 -> Anything bigger 400 don?t.
I guess that for some reasons ImeageCreateTrueColor don?t like big numbers.. but i have no Ideas why.
The image i used was a Standart jpg with 1600*1200. Size played no role.

I would really apreciate your help on this topic, as i will definitly extend this genius hack !

What i want to add:
-Other extension (.jpeg,.jpe ...)
-File size

Does anybody know if GDlib can read EXIF Data ?

(Yes my English sucks )
Reply With Quote
  #43  
Old 03-10-2005, 02:52 PM
John_44 John_44 is offline
 
Join Date: Aug 2004
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry. It works with 450 and 500. But 600 is to mutch. This makes me sick.

(And it is not "ImageCopyResampled". The following line works just fine:

ImageCopyResampled($ni,$im,0,0,0,0,1000,$nh,$w,$h) ; )
Reply With Quote
  #44  
Old 03-10-2005, 04:45 PM
John_44 John_44 is offline
 
Join Date: Aug 2004
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If somebody else has the same Problem: As a workaround i use:

$width_factor = $w / 500;
$height_factor = $h / 500;
if ($width_factor > $height_factor)
{
$nw = round($w / $width_factor);
$nh = round($h / $width_factor);
}
else
{
$nw = round($w / $height_factor);
$nh = round($h / $height_factor);
}

$ni=imagecreatetruecolor($nw,$nh);
ImageCopyResampled($ni,$im,0,0,0,0,$nw,$nh,$w,$h);
UnsharpMask($ni);
Reply With Quote
  #45  
Old 03-10-2005, 07:43 PM
John_44 John_44 is offline
 
Join Date: Aug 2004
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

And i found a Bug: If more than one Image is resized, the script returns an error 500. However the first one is still uploaded.

Anybody else with this error ?
Reply With Quote
  #46  
Old 03-29-2005, 02:02 AM
nosaj nosaj is offline
 
Join Date: Mar 2005
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks mini2, installed and working on my vBulletin Version 3.0.7 Forum. :classic:
Reply With Quote
  #47  
Old 03-31-2005, 06:20 PM
LiewCF's Avatar
LiewCF LiewCF is offline
 
Join Date: Mar 2005
Location: Malaysia
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great! this hack work for my bloggers forum. There is other similar hack too, but it does not work.

Thank you!
Reply With Quote
  #48  
Old 04-03-2005, 10:09 AM
JohnBee JohnBee is offline
 
Join Date: Oct 2004
Posts: 544
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I started to install this hack on 3.0.3
but in the functions_file.php I could not find the section that says:

Code:
@unlink($attachment);
eval('$error = "' . fetch_phrase('attachbaddimensions', PHRASETYPEID_ERROR) . '";');
$errors[] = array(
	'filename' => $attachment_name,
	'error' => $error...
is there another portion of code I should look for?
Reply With Quote
  #49  
Old 04-18-2005, 09:00 PM
Blam Forumz Blam Forumz is offline
 
Join Date: Jun 2004
Posts: 554
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

for attachments is it possible for them to be clikabkle?
Reply With Quote
  #50  
Old 04-25-2005, 01:32 AM
Harley D's Avatar
Harley D Harley D is offline
 
Join Date: Jan 2003
Location: WagnerTech.net
Posts: 266
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by mini2
No idea on the darker image, I cant reproduce the problem.
I have a PHP Store that has pic resizing, and I've found that gif, jpegs, and pngs.... one of those will darken when resized. try changing the type of file and upload it to see how it renders after being resized.
Reply With Quote
  #51  
Old 04-25-2005, 01:37 AM
Harley D's Avatar
Harley D Harley D is offline
 
Join Date: Jan 2003
Location: WagnerTech.net
Posts: 266
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Hexemer
Hello,

first, thank you for this nice hack.

But, I have a Problem. :disappointed: The uploaded picture is "darker" than the original one.

attachment 1: original
attachment 2: uploaded in my forums

gd version: 2.0.12

Can you help me? :ermm:

I did some more checking and found that .JPG will darken but .GIF doesn't.
So use paint shop or photo shop to change from a JPG to GIF, this should solve this problem. If it does, please post so other will know if it works.
Reply With Quote
  #52  
Old 05-07-2005, 12:25 AM
Razasharp's Avatar
Razasharp Razasharp is offline
 
Join Date: Feb 2005
Location: UK
Posts: 373
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Excellent hack! *clicks install* Does exactly what is says on the tin :-)

Just a quick question tho, do the 'original' large files automatically get deleted off the server or do we have to do that manually?

Also a note for people using the attachment resizer, you have to 'increase' the sizes in your ACP to let the larger files get uploaded to then be resized. :-)
Reply With Quote
  #53  
Old 05-18-2005, 11:28 PM
Razasharp's Avatar
Razasharp Razasharp is offline
 
Join Date: Feb 2005
Location: UK
Posts: 373
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sometimes the images shown (JPG) are a bit dark... anyway to get them lighter? :-/

Most users wont know how to conver to gif, so thats not any option really...
Reply With Quote
  #54  
Old 05-26-2005, 06:06 PM
Bounce's Avatar
Bounce Bounce is offline
 
Join Date: Mar 2004
Location: Edinburgh,Scotland
Posts: 919
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Uploaded all as per instructions,doesn't seem to be working

Do you need safe mode turned off for this to work...

Uploaded the 2 hacks,no errors or anything but doesn't work :ermm:

Edit: Got the avatar hack working,slight problem same as another user, the pic is slightly darker
Reply With Quote
  #55  
Old 06-30-2005, 07:20 AM
lionslair lionslair is offline
 
Join Date: Apr 2005
Location: Western Australia
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for that wiked hack
Reply With Quote
  #56  
Old 07-31-2005, 04:02 AM
kobescoresagain kobescoresagain is offline
 
Join Date: Feb 2005
Posts: 327
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

anyone know if you can intergrate this into vb gallery?
Reply With Quote
  #57  
Old 08-05-2005, 05:41 AM
kmike kmike is offline
 
Join Date: Oct 2002
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Excellent hack.
I see a couple of small problems with it though:
  1. it doesn't handle additional image types supported by getimagesize() PHP function, e.g. .SWF, .PSD, and .BMP. First two are probably non-issue, but our forum has .bmp attachments enabled, and this hack will generate an empty resized image for them
  2. a huge image can cause "out of memory" PHP error on ImageCopyResampled() call, and the hack doesn't handle these situations (I think 500 errors cited in this thread are caused exactly by this - check your error logs for PHP errors)
  3. the attachment file size stored in the db is wrong - the stored number is the size of original attachment, not the resized one. the total space occupied by member's attachments will be wrong, which may cause problems if attachment quotas are defined for usergroups
  4. some memory could be freed during script execution by adding ImageDestroy() calls in the proper places
  5. I think UnsharpMask() call is only needed if the attachthumbs option in admin CP set to "Yes - sharpen" (to be consistent with thumbnails handling)
  6. there's no need to mess with "require_once('./includes/functions_image.php');" line at all. The file is only included once, if needed

I've fixed these problems, and also did some code cleanup.
You can uncomment error_log() lines and change email to your actual address to get some idea how this hack performs.

Code:
				// HACK: auto resize uploaded images
				switch ($imginfo[2])
				{
				case 1:
                			$im = ImageCreateFromGIF($attachment);
					break;
				case 2:
                			$im = ImageCreateFromJPEG($attachment);
					break;
				case 3:
                			$im = ImageCreateFromPNG($attachment);
					break;
				// no way to handle these image types
				default:
					// error_log("Couldn't resize $attachment ($filesize bytes)", 1, "email@yourdomain.net");
					@unlink($attachment);
					eval('$error = "' . fetch_phrase('attachbaddimensions', PHRASETYPEID_ERROR) . '";');
					$errors[] = array(
						'filename' => $attachment_name,
						'error' => $error
					);
					return false;
				}

				$w = $imginfo[0];
				$h = $imginfo[1];
				$width_factor = $w / $maxattachwidth;
				$height_factor = $h / $maxattachheight;
				if ($width_factor > $height_factor)
				{
					$nw = round($w / $wdth_factor);
					$nh = round($h / $wdth_factor);
				}
				else
				{
					$nw = round($w / $height_factor);
					$nh = round($h / $height_factor);
				}

				$ni = @ImageCreateTrueColor($nw, $nh);
				if ($ni OR !@ImageCopyResampled($ni, $im, 0, 0, 0, 0, $nw, $nh, $w, $h))
				{
					// failed to resize this image
					// error_log("Couldn't resize $attachment ${w}x${h} to ${nw}x${nh} ($filesize bytes)", 1, "email@yourdomain.net");
					@unlink($attachment);
					eval('$error = "' . fetch_phrase('attachbaddimensions', PHRASETYPEID_ERROR) . '";');
					$errors[] = array(
						'filename' => $attachment_name,
						'error' => $error
					);
					return false;
				}
				@ImageDestroy($im);
				if (PHP_VERSION != '4.3.2' AND $vboptions['attachthumbs'] == 2)
				{
					require_once('./includes/functions_image.php');
					UnsharpMask($ni);
				}
				switch ($imginfo[2])
				{
				case 1:
					@ImageGIF($ni, $attachment);
                			break;
				case 2:
					@ImageJPEG($ni, $attachment, 70);
					break;
				case 3:
					@ImagePNG($ni, $attachment);
					break;
				}
				@ImageDestroy($ni);
				$filesize1 = @filesize($attachment);
				// error_log("Resized $attachment ${w}x${h} to ${nw}x${nh} ($filesize to ${filesize1})", 1, "email@yourdomain.net");
				$filesize = $filesize1;
				// /HACK
Reply With Quote
  #58  
Old 08-08-2005, 12:41 AM
mvigod mvigod is offline
 
Join Date: Dec 2001
Location: Jersey
Posts: 159
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

kmike,

nice fixes. has anyone tested this yet on 3.5 RC2?
Reply With Quote
  #59  
Old 08-31-2005, 02:51 PM
thephonemall thephonemall is offline
 
Join Date: Oct 2004
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am getting this error when attempting the Profile Pic modification:

Fatal error: Call to undefined function: unsharpmask() in /home/website/forums/includes/functions_upload.php on line 294

EDIT:

Nevermind added
require_once('./includes/functions_image.php');
and it works!
Reply With Quote
  #60  
Old 10-25-2005, 12:39 PM
MrNase MrNase is offline
 
Join Date: May 2003
Location: Germany
Posts: 670
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can this one please be ported to vB3.5?
Reply With Quote
  #61  
Old 11-14-2005, 08:41 AM
lazytown lazytown is offline
 
Join Date: Feb 2004
Posts: 503
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

A port to 3.5 would be VERY useful.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:37 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.09251 seconds
  • Memory Usage 2,516KB
  • Queries Executed 45 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (2)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (31)post_thanks_box
  • (31)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (31)post_thanks_postbit_info
  • (30)postbit
  • (31)postbit_onlinestatus
  • (31)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete