vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Beta Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=5)
-   -   Server-side Thumbnailed Attachments (https://vborg.vbsupport.ru/showthread.php?t=59410)

CVMagic 12-27-2003 10:00 PM

Server-side Thumbnailed Attachments
 
Thumbnailed Attachments Version 1.0

Description: Its kind of Self explanitory, but in anycase if you dont know what it does, it checks if an attached image is larger than your specified size and if it is it will use ImageMagick, Netpbm, or the GD Image functions to resize it accourdingly using a rather simple formula to make sure the thumbnails are kept in scale.

Usual Mod Warning: This moddification unlike most other thumbnailed attachment mods isn't only a template hack so mind you, you'd have to make sure you backup your files before using this hack.

Screenshots/Test Threads: I have one included below and this link contains a vB that has already been modded: http://www.cheatandwin.com/forums/sh...=&threadid=216. But i should let you know that both are kind of outdated already since i did update the instructions from an oversight i had made earlier..

Requirements: Umm, as vB goes i'd say you'd need 2.2.x or higher but i designed it under 2.3.3 so there might be slight differences namely in the templates but not much to worry about that..
PHP 4.0.6 <- For the moment that is the minimum requirement for the modifications i have made aside to the ones required for vB
Any of the following 3: ImageMagick, Netpbm, or GD 2.01 or higher

Thats about it, any comments, suggestions, or questions feel free to post here or even email me personally at cvmagic at cheatandwin dot com.

[edit]
New Updated Version Download Today!

Shell Geeks 12-28-2003 07:49 AM

intresting hack, but in your sample forum, some of the desktop photos didn't resize and they scroll hella far to the right. I might install this later today.

MindTrix 12-28-2003 08:17 AM

Nice idea although i believe something similar has been done. Ill be sure too check this out later, Thanks

CVMagic 12-28-2003 08:54 AM

@Shell Geeks:
actually in that demo i took an exsisting thread, and for a while the users thought that the attachments didnt work, so they posted with image tags, look at the source if you want..

@MindTrix:
I do hope not, lol when i started the hack earlier today or yesterday im not sure lol, i did a simple search for this hack and only could find the template versions of this hack( in the sence that they'd use the image tags to resize for them client side) or a gallery hack but not one that directly modified attachment.php to generate the thumbs

MindTrix 12-28-2003 09:23 AM

In which case it hasnt been made then, so Congrats!!!

Im also guessing this is your first hack here at vb.org so congratulations on that also, hope to see more from you :)

Long Live vB2!!!

Dean C 12-28-2003 10:03 AM

Looks good - I know a client of mine was looking for this so thanks ;)

chrisvonc 12-28-2003 12:56 PM

Hmm.. nice, I will try this on my test forum. How will yours handle images smaller than the values you set up? The thumbnail hack I use now wont ignore smaller images sizes and will resize them up to the set values.

Just as a FYI, there are 2 other "thumbnailing" hacks, one as you pointed out is template, the other is vbcode.
https://vborg.vbsupport.ru/showthread.php?t=52685
https://vborg.vbsupport.ru/showthrea...threadid=52344

Chris :)

gmarik 12-28-2003 03:47 PM

still doen't get what it is, what's for rour XP screenshot?

CVMagic 12-28-2003 05:50 PM

@gmarik:
Well the screenshot shows a thumb that was created from a 1280 x 780 image, I needed to pick something that most people would think was big.

@chrisvonc:
Yes, smaller images arent resized they are in actuality are the original image, so needing to load the GD libraries is not required.

@MindTrix:
^_^ yes it is my 1st hack, i wanted my first post to be one

Slynderdale 12-29-2003 08:00 AM

Is there a way to cache the thumbnail? Your current method isn't effiecent. If the forum has alot of image attachments, this hack could bog down the server because it would have to dynamicly create the thumbnail each time the page loads. Also I looked at the code, if the thread has quite a few images atatched, it will greatly increase the page load time because it generated each thumbnail and uses resampling which isn't the fastest method but the best quality method.

This hack is great for small forums, but larger ones that have alot of attached images would see a performance decrease if they have alot of page views.

CVMagic 12-29-2003 02:00 PM

Quote:

Originally Posted by Slynderdale
Is there a way to cache the thumbnail? Your current method isn't effiecent. If the forum has alot of image attachments, this hack could bog down the server because it would have to dynamicly create the thumbnail each time the page loads. Also I looked at the code, if the thread has quite a few images atatched, it will greatly increase the page load time because it generated each thumbnail and uses resampling which isn't the fastest method but the best quality method.

This hack is great for small forums, but larger ones that have alot of attached images would see a performance decrease if they have alot of page views.

actually slynderdale thats what im doing now, im coding that and along with a CP frontend, the only trouble is that im trying to avoid extra database queries than i have to so im trying to think of a method to allow some sort of cacheing, either by creating a temp folder where all the thumbnails would be stored and looked up for, or create a new database table to contain all the thumbnails which would be processed when you post the attachment rather than when viewing it...

CVMagic 12-30-2003 01:31 AM

I dont mean to double post, but since no one has replied yet i have to,... I actually got the requested cache in place and options added in the Admin panel under options so you wont need to edit attachments.php everytime you want to change thumbnail sizes or change cache directories, i have included updated instructions, and im planning to add upgrade instructions just incase( i doubt you'd need it tho because its all simple enough )...

[File Updated, Please download it again if you have downloaded it already]

FleaBag 12-31-2003 02:50 PM

Excellent hack, just what I was looking for to be honest. A lot of my users like to post photographs of themselves and gigs they've been to, only trouble is my forum has an 800 pixel width, which always gets shunted around when people post large images. This is ideal. :D

Thanks!

CVMagic 12-31-2003 06:41 PM

^_^ thanks, if your all interested im soon going to take this hack and add it support to scott's filebased attachements then officially release it, because it seems from all the forum versions i've tested it with its been rather flawless, and when it hasnt it were mainly due to permission issues on setting up the directories, lol yeah i dont follow my own instructions :-P

aliencode 12-31-2003 08:10 PM

Any chance of getting Image Magick support for this great hack?

CVMagic 12-31-2003 08:34 PM

Sure, ill add that to my todo list

aliencode 01-01-2004 04:51 PM

That would be great CVMagic - Im running 3 gamma now and I know it has integrated thumbnailing of attachments but GD is limited to certain filetypes. ImageMagick supports almost all image formats, plus its much easier to install for those of us with our own servers. Much appreciated I like your clean mod.

CVMagic 01-01-2004 06:35 PM

by the way as for ImageMagick intergration do you perfer just running direct exec commands or having ImageMagick Commands intergraded into php? I much Perfer the intergraded ones over exec ones because of security reasons and the fact that some servers disallow exec commands but the thing about intergraded ones for php is that you have to rebuild your server, so ill code it accourding to what you think is best in this case.

aliencode 01-01-2004 06:56 PM

Either way would be fine I would imagine, vbulletin is commercial product that is normally run on a dedicated server anyways. I personally have written most of my thumbnailing scripts using the system commands, ya know adding both types wouldnt really be hard since the system commands are one line using convert program.

CVMagic 01-02-2004 08:27 AM

^_^ okay im done, i just added support for No Imaging for those people who wanted to add this hack and planning to move to a new server that has GD or otherwise soon, Netpbm Support which i frankly like better than both GD and ImageMagick, ImageMagick Support for those people who want it :-D, GD2 was there already but now i have function verification so you wont get those nasty errors if lets say you dont have 2.0.1 or higher installed, and i made sure that scott's attachments as files hack wont interfere, as a side note when scott released that he was still a genious since i still dont have to modify any of his code to make this hack to work which may i say i was happy about....
So overall the requirements needed now to run this hack now are none, the requirements are set to whatever functions you have set to work rather than just GD...
Oh and i also made sure that possible security holes are covered to avoid someone sneaking in a abritary command when converting ;)...
It will be posted on the 1st post as an attachment, enjoy :)

aliencode 01-02-2004 03:07 PM

CVMagic - excellent hack - this is how hacks should be made, clean simple, not much modification. Thank you kindly!

AutomatikStudio 01-02-2004 07:54 PM

Hmm...well I added the script but I'm getting broken images now and when you click on the broken thumbnail image it takes you to the real picture.

CVMagic 01-02-2004 11:49 PM

that is odd, can you add '&dl=1' to the attachment url and post the results of the error..

CVMagic 01-04-2004 01:15 AM

Okay, I debugged the issue, and it was a simple error in my part that my version of php for windows didnt pick up which i odd i must say so here is the simple fix

Code:

-----------
find
-----------
if($dc=0){

-----------
Replace with
-----------
if(!($dc==1)){

###########

Done ^_^

It has already been applied to the 1.5 version so all is well, and thank you for pointing the error out AutomatikStudio

tcs 01-09-2004 12:27 AM

Nice hack, however I have a problem. I set the max size of an image to 200x200 and the size to 1 mb. I try to upload a file that is 500x400 and vb warns that the image is too big to upload. (Exceeds the 200x200 I set)

I am on VB 2.3.3
I have no other hacks installed in the attachments.php
I ran the Sql quarries and verified there existence in the db
I triple checked the php additions
I have disable GD 2+ and tried enabled as well
I set the imagemagak 2 1 and have the exact path.

It is making a image to the thumbs folder but not the size I told it to. "150x150"
If I up the size of my image allowance it uploads the image and does say "Click here to enlarge" but the image in the thread is the same size as the attached image in the thread.

Hope I explained this well enough. Let me knoe if not.

Chuck

pigsy 01-12-2004 05:59 PM

Had some problems getting this to work.

The problems I've encountered were:

1. The main problem is because it resizes on the fly when a page loads. If you're applying to this hack to a busy site, you can sometimes as we do have 5+ images in a thread. Although it seems to work when there's just one image, any more and it seems like the script doesn't have long enough to complete the conversion and you end up with broken images, and corrupt files in the thumbs dir. Is there any way to give the script time to generate the thumbnails. Alternatively if a script could be created to convert all images store in the directory in one hit, might take some time, but its where you'll eventually end up - and I think it can cope with converting one image on a thread as a new post is made.

2. ImageMagick worked in that it created a resized thumbnail but for some reason it generated the name without quotes - but the script is expecting those since it uses the php function escapeshellarg for the filename. Anyone know a way round this?

3. Couldn't get NetPBM to reduce the image size, it simply created a copy of the oversized image to display.

Great hack, and potentially what I've been looking for - but unworkable on my forum unfortunately. Any assistance much appreciated.

CVMagic 01-27-2004 02:04 PM

:-P what can i say, sorry about the delay... i should note that with safemode this hack does not run well at all, I didnt code it with making it safemode compatible in mind at all..., but as in multiple images at a time, it should work just fine because w/o safemode the images have all the time in the world to complie its thumbnails and plus if a user were to press stop it still continues on its own(again not safe mode compatible)... but noted i was using a much older version of netphm and imagemagick so it might not work as i intended at all, but dont worry at all im working on a newversion that instead of processing the attachment on post view it will do it during the post thus be safemode compatible in a sence...

CVMagic 01-27-2004 02:10 PM

Quote:

Originally Posted by tcs
Nice hack, however I have a problem. I set the max size of an image to 200x200 and the size to 1 mb. I try to upload a file that is 500x400 and vb warns that the image is too big to upload. (Exceeds the 200x200 I set)

I am on VB 2.3.3
I have no other hacks installed in the attachments.php
I ran the Sql quarries and verified there existence in the db
I triple checked the php additions
I have disable GD 2+ and tried enabled as well
I set the imagemagak 2 1 and have the exact path.


It is making a image to the thumbs folder but not the size I told it to. "150x150"
If I up the size of my image allowance it uploads the image and does say "Click here to enlarge" but the image in the thread is the same size as the attached image in the thread.

Hope I explained this well enough. Let me knoe if not.

Chuck

Well Chuck it seems that you had two problems that were not related to this hack at all, the size limit that you set it to limit the size of the upload itself not the thumb so if you upload 500x400 image it might just have been way too big for your settings to allow, now as for the 150x150 image there could be 2 problems, one you have GD disabled or php does not see it at all so it just lets the image pass on because it has nothing else it can do, or the image your uploading itself is smaller than 150x150

FeKuLa 01-29-2004 06:39 AM

Can you help me CVMagic?

In my forum, I obtain any broken thumbnails, look:

http://www.indicedivx.com/foro/showt...threadid=24416

OR

http://www.indicedivx.com/foro/showt...threadid=23930

(You need register for show thumbs. Login: testing, pass: testing)

Thanks

CVMagic 01-29-2004 07:18 AM

I've PMed you on your site already with the name: CVMagic, but in anycase if you have blocked out PMs, there might be 2 issues one that the file was somehow interupted during thumbnail generation which your solution would to be just deleting all the thumbs and let the script generate all the thumbs again, if its the second issue til this day gets me which is the your using GD2 it as some problem with some gif files and wont allow it to go beyond reading it at all which then i'd just either recommend disabling gif file uploading or getting Imagemagick or Netphm with gif/jpeg/jpeg2000/png support and using them as your method to thumbnail images...

[edit] There is another method too, actually its a work around if you dont want to install those other 2 programs, it means that those bad gif files will go unresized but hey its alot better than an X no? well here is the code you need to replace:
PHP Code:

    }
    else
    {
    
imagedestory($simg);
    
$dc=0;
  }
 } 

Replace that with:
PHP Code:

    }
    else
    {
    if(
function_exists(imagedestory)){
         
imagedestory($simg);
    }
    
$dc=0;
  }
 } 


tcs 01-29-2004 10:58 AM

Thanks for the reply. I have tried many different settings to no avail. I am of the opinion there is a server issue with imagemagik and GD. Don't know what it is yet.

Thanks for the reply...

memobug 01-30-2004 05:59 AM

Will this be ported to vB3? I will be your dearest friend. Well, not quite that dear!

Regards,

Matt

FeKuLa 01-30-2004 04:46 PM

Thank you CVMagic, my problem is solved :)

CVMagic 01-31-2004 03:28 AM

@tcs:
Can you try out one of the attachments and add &dl=1 to the url address and tell me what error it says, it might be a simple error that i could fix for you...
@memobug:
I believe vB3 has it built in but ill take a look at it and make it so, just as long as there is a demand for it

memobug 01-31-2004 06:44 AM

Hi CVMagic,

The resizing of image attachments to conform to max pixel sizes is not built in to vB3. What is integrated is a thumbnailing feature that will take your attachment (whatever size it is) and produce a thumbnail image that can be used for inline display (default is 100pix) - linked to the original, unresized image.

vB3 does not manipulate images to conform to max size standards. If size checking is enabled, it will simply say the image is too large.

For those others who have asked about having an auto-size feature, it was recommended at Vbulletin.com that a hack be requested at Vbulletin.org. I have seen a few requests already for avatar and profile picture resizing on this forum, too, so I am sure there is a demand for autosizing.

Best,

Matt

pigsy 02-01-2004 03:47 PM

Hi CVMagic,

Many thanks for your feedback. Regarding safemode, I don't actually have this turned on and I don't have a particularly short timeout for scripts because some of the ones I run last 60 secs. Can you point me in the direction of any apache/php/linux settings that might give rise to problems when processing multiple images - and end up with broken images.

I feel there's still hope for me, if I could just figure what's wrong. Nice work all the same.

mskgr 02-06-2004 08:17 PM

Fatal error: imagecreatetruecolor(): requires GD 2.0 or later in /var/www/html/myphone/forum/attachment.php on line 199


Well, I have to say that $ImageMagick_enabled=1; and my path for imagekick is OK ('/usr/X11R6/bin/'), as I already use it for photopost.

So, what's wrong :)

mskgr 02-06-2004 08:42 PM

Now I get strange errors... Somethign changed but I don't know what :)

Code:

<br>
<b>Warning</b>:  stat failed for ./thumbs/'claudia.jpg'.tmp.155 (errno=2 - No such file or directory) in <b>/var/www/html/myphone/forum/attachment.php</b> on line <b>174</b><br>
<br>
<b>Warning</b>:  Cannot add header information - headers already sent by (output started at /var/www/html/myphone/forum/attachment.php:174) in <b>/var/www/html/myphone/forum/attachment.php</b> on line <b>174</b><br>
<br>
<b>Warning</b>:  fopen("./thumbs/'claudia.jpg'.tmp.155", "rb") - No such file or directory in <b>/var/www/html/myphone/forum/attachment.php</b> on line <b>175</b><br>
<br>
<b>Warning</b>:  Supplied argument is not a valid File-Handle resource in <b>/var/www/html/myphone/forum/attachment.php</b> on line <b>176</b><br>
<br>
<b>Warning</b>:  Supplied argument is not a valid File-Handle resource in <b>/var/www/html/myphone/forum/attachment.php</b> on line <b>177</b><br>

And yes, there is a thumbs directory on my forum path. And it's changed to 777, and guess what I see .tmp files in there :)

CVMagic 02-07-2004 01:49 AM

Quote:

Originally Posted by mskgr
Fatal error: imagecreatetruecolor(): requires GD 2.0 or later in /var/www/html/myphone/forum/attachment.php on line 199


Well, I have to say that $ImageMagick_enabled=1; and my path for imagekick is OK ('/usr/X11R6/bin/'), as I already use it for photopost.

So, what's wrong :)

That might just mean that ImageMagick was not setup correctly so i skips over to the next thing which is GD, and seeing that your the rare few with GD 2.0 it passed the function checks but still you get that error.

CVMagic 02-07-2004 01:51 AM

Quote:

Originally Posted by mskgr
Now I get strange errors... Somethign changed but I don't know what :)

Code:

<br>
<b>Warning</b>:  stat failed for ./thumbs/'claudia.jpg'.tmp.155 (errno=2 - No such file or directory) in <b>/var/www/html/myphone/forum/attachment.php</b> on line <b>174</b><br>
<br>
<b>Warning</b>:  Cannot add header information - headers already sent by (output started at /var/www/html/myphone/forum/attachment.php:174) in <b>/var/www/html/myphone/forum/attachment.php</b> on line <b>174</b><br>
<br>
<b>Warning</b>:  fopen("./thumbs/'claudia.jpg'.tmp.155", "rb") - No such file or directory in <b>/var/www/html/myphone/forum/attachment.php</b> on line <b>175</b><br>
<br>
<b>Warning</b>:  Supplied argument is not a valid File-Handle resource in <b>/var/www/html/myphone/forum/attachment.php</b> on line <b>176</b><br>
<br>
<b>Warning</b>:  Supplied argument is not a valid File-Handle resource in <b>/var/www/html/myphone/forum/attachment.php</b> on line <b>177</b><br>

And yes, there is a thumbs directory on my forum path. And it's changed to 777, and guess what I see .tmp files in there :)


You have the safemode problem, but give me a link ill look into it directly for you.


All times are GMT. The time now is 08:03 AM.

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.01386 seconds
  • Memory Usage 1,856KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (2)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete