TinyPortal

Development => Support => Topic started by: sturmkatze on September 16, 2008, 02:47:55 AM

Title: is there a mod or add-on...
Post by: sturmkatze on September 16, 2008, 02:47:55 AM
... that will allow pix to be shrunk without using some third party site or program? I have a lot of members who are not as computer/Internet saavy as many of us and they get frustrated at things and I am trying to make it easier for them. I Guess that I'll prob have to also write/re-write some tutorials for them :-0
Title: Re: is there a mod or add-on...
Post by: Ianedres on September 16, 2008, 03:13:52 AM
If, by chance, you are speaking of posting pictures within messages in SMF, you can use the height and width elements in the IMG tag to change the dimensions; the downloaded file size will not change.

[IMG height=300 width=400]image[/IMG]
Title: Re: is there a mod or add-on...
Post by: JPDeni on September 16, 2008, 05:01:07 AM
I wrote a gallery for my site, because I didn't like any of the other galleries I could find. I borrowed some code from MKPortal to create thumbnails.

I'll take a look at it tomorrow and see if I can find the code for that. I haven't looked at the source for a couple of years.
Title: Re: is there a mod or add-on...
Post by: JPDeni on September 16, 2008, 04:37:49 PM
Okay. I've taken a look at my code. I'm just not sure where you would put it.

What this does is takes an image that has been uploaded already, the name of which is in the $image variable, and makes a copy of it that is 120 pixels wide, with a height that is proportional to the original. Then it saves it into another directory ($dest). In my case, I'm creating thumbnails. The original is not changed.



$directory = '/path/to/image/directory'; // This is *not* a URL!!!!
$source = "$directory" . '/' . "$image";
$dest = "$directory" . '/' . "$thumb";
CreateImage(120,$source,$dest);

function CreateImage($size,$source,$dest,$border=0) {

  $imgsize = GetImageSize($source);
  $width = $imgsize[0];
  $height = $imgsize[1];
  $new_width = $size;
  $new_height = ceil($size * $height / $width);
  $im = @ImageCreateFromJPEG($source);

  $new_im=@ImageCreateTrueColor($new_width,$new_height);
   if ($new_im) {
    ImageCopyResized($new_im,$im,0,0,0,0,$new_width,$new_height,ImageSX($im),ImageSY($im));
    ImageJPEG($new_im,$dest,90);
    ImageDestroy($new_im);
  }
}


To tell you the truth, I haven't used this for quite a while, so I'm not sure it still works. It used to, though. :)
Title: Re: is there a mod or add-on...
Post by: Dragooon on September 16, 2008, 04:57:47 PM
You can also use the createThumbnail function found in Subs-Graphics.php
Title: Re: is there a mod or add-on...
Post by: JPDeni on September 16, 2008, 05:28:53 PM
Cool!  :D I guess I should take a look at those functions one of these days. :2funny:
Title: Re: is there a mod or add-on...
Post by: Dragooon on September 16, 2008, 06:03:31 PM
lol :P
Yeah the function in Subs- files are pretty useful.
Title: Re: is there a mod or add-on...
Post by: sturmkatze on September 19, 2008, 04:03:54 AM
I don't even know what the function in Subs-Graphics.php are... sounds out of my league. I'm still trying to remember not to have ' without an / before it :-Þ
Title: Re: is there a mod or add-on...
Post by: JPDeni on September 19, 2008, 04:35:17 AM
Exactly what are you trying to do? Do you want to add something to a mod or to have a separate script to resize existing files? Or....?

I'd tell you what the function is, but I don't think it would do you any good unless we know what to do with it.
Title: Re: is there a mod or add-on...
Post by: sturmkatze on September 19, 2008, 04:43:56 AM
Okay, I have another site at The Dog's Place (http://www.the-dogs-place.com) and I would like it so that when members wish to upload pix of their dogs (and they do EVERY DAY), that they won't be uploading some 2000 pixel wide monster. I'd like to have to auto-re-sized to something like 500 pixels... The dog website they used to be on (which died) had a neato thing that when they uploaded their pix, it let them crop it and then re-sampled the photo and re-sized it too. That's what I'm looking for as many of our members are NOT computer saavy and don't wish to be, really... they just want to share pix of their dogs. ;)