Topic: Limit Image Sizes in Sigs

I would like to limit the image size people are allow to put in sigs.
Does anyone know how this can be done? A Plug-in, mod or something of that sort?

Thank you guys.

2

Re: Limit Image Sizes in Sigs

Sig images are usually remotely hosted, so I don't think PunBB can check image dimensions on them.  Not without a mod to host sigs locally anyway, and further modding to check filesize and dimensions before accepting the upload.

Re: Limit Image Sizes in Sigs

Makes sense. Alright, thank you.

Re: Limit Image Sizes in Sigs

getimagesize()

From the PHP manual:

getimagesize

(PHP 3, PHP 4, PHP 5)
getimagesize -- Get the size of an image
Description
array getimagesize ( string filename [, array &imageinfo] )

The getimagesize() function will determine the size of any GIF, JPG, PNG, SWF, SWC, PSD, TIFF, BMP, IFF, JP2, JPX, JB2, JPC, XBM, or WBMP image file and return the dimensions along with the file type and a height/width text string to be used inside a normal HTML <IMG> tag.

If accessing the filename image is impossible, or if it isn't a valid picture, getimagesize() will return FALSE and generate an error of level E_WARNING.

    Note: Support for JPC, JP2, JPX, JB2, XBM, and WBMP became available in PHP 4.3.2. Support for SWC exists as of PHP 4.3.0 and TIFF support was added in PHP 4.2.0 

    Note: JPEG 2000 support was added in PHP 4.3.2. Note that JPC and JP2 are capable of having components with different bit depths. In this case, the value for "bits" is the highest bit depth encountered. Also, JP2 files may contain multiple JPEG 2000 codestreams. In this case, getimagesize() returns the values for the first codestream it encounters in the root of the file. 

    Note: The getimagesize() function does not require the GD image library. 

Returns an array with 4 elements. Index 0 contains the width of the image in pixels. Index 1 contains the height. Index 2 is a flag indicating the type of the image: 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM. These values correspond to the IMAGETYPE constants that were added in PHP 4.3.0. Index 3 is a text string with the correct height="yyy" width="xxx" string that can be used directly in an IMG tag.

Example 1. getimagesize (file)
<?php
list($width, $height, $type, $attr) = getimagesize("img/flag.jpg");
echo "<img src=\"img/flag.jpg\" $attr alt=\"getimagesize() example\" />";
?>

URL support was added in PHP 4.0.5

Example 2. getimagesize (URL)
<?php
$size = getimagesize("http://www.example.com/gifs/logo.gif");

// if the file name has space in it, encode it properly
$size = getimagesize("http://www.example.com/gifs/lo%20go.gif");

?>

With JPG images, two extra indexes are returned: channels and bits. channels will be 3 for RGB pictures and 4 for CMYK pictures. bits is the number of bits for each color.

Beginning with PHP 4.3.0, bits and channels are present for other image types, too. However, the presence of these values can be a bit confusing. As an example, GIF always uses 3 channels per pixel, but the number of bits per pixel cannot be calculated for an animated GIF with a global color table.

Some formats may contain no image or may contain multiple images. In these cases, getimagesize() might not be able to properly determine the image size. getimagesize() will return zero for width and height in these cases.

Beginning with PHP 4.3.0, getimagesize() also returns an additional parameter, mime, that corresponds with the MIME type of the image. This information can be used to deliver images with correct HTTP Content-type headers:

So yes, it can be done, assuming that the host's PHP version is > 4.3.0 smile

5

Re: Limit Image Sizes in Sigs

The trouble with that is if the images are on slow servers it can bring the page to a standstill. We've tried it (I suggested it, Rickard coded it) and it was a bad idea.

Re: Limit Image Sizes in Sigs

True... you could try to ping the server the image is on when the signature gets submitted. If it reaches x ms you don't parse it. Would create a simple solution, but a huge speed decrease in the signature submit part.