TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,973
  • Latest: NonStop
Stats
  • Total Posts: 196,230
  • Total Topics: 21,353
  • Online today: 446
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 508
  • Total: 508

is there a mod or add-on...

Started by sturmkatze, September 16, 2008, 02:47:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sturmkatze

... 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

Ianedres

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]

JPDeni

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.

JPDeni

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. :)

Dragooon

#4
You can also use the createThumbnail function found in Subs-Graphics.php

JPDeni

Cool!  :D I guess I should take a look at those functions one of these days. :2funny:

Dragooon

lol :P
Yeah the function in Subs- files are pretty useful.

sturmkatze

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 :-Þ

JPDeni

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.

sturmkatze

Okay, I have another site at The Dog's Place 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. ;)

This website is proudly hosted on Crocweb Cloud Website Hosting.