Jump to content

Regulate "Image Size" and "Image Dimensions"?


doubledee

Recommended Posts

Do I need to check both the "Image Size" AND "Image Dimensions" for files that Users upload to my website?

 

Currently I have...

// ********************
// Check File-Size.		*
// ********************
if (empty($errors)){
	// Check File-Size in Bytes.
	if (filesize($tempFile)<4000){
		// File too small.
		$errors['upload'] = 'File-size must be greater than 4 Kilobytes.';
	}elseif (filesize($tempFile)>100000){
		// File too big.
		$errors['upload'] = 'File-size must be less than 100 Kilobytes.';
	}else{
		// File-Size Okay.
		// Continue Processing Upload...
	}
}//End of CHECK FILE-SIZE

 

 

I guess I haven't been worrying about "File Dimensions" because I resize everything here...

// **********************
// Set New Dimensions.	*
// **********************

// Capture Dimensions on Original Image.
$origWidth = imageSX($origImage);
$origHeight = imageSY($origImage);

if ($origWidth > $origHeight){
	$newWidth = 100;
	$multiplier = $newWidth/$origWidth;
	$newHeight = $origHeight * $multiplier;
}

if ($origWidth < $origHeight){
	$newHeight = 100;
	$multiplier = $newHeight/$origHeight;
	$newWidth = $origWidth * $multiplier;
}

if ($origWidth == $origHeight){
	$newWidth = 100;
	$newHeight = 100;
}

 

Thanks,

 

 

Debbie

 

Link to comment
Share on other sites

Do I need to check both the "Image Size" AND "Image Dimensions" for files that Users upload to my website?

 

Only if you feel it necessary.  If your only going to use resized copies and not the original anywhere than dimensions is less of a concern probably as you'll have them standardized.

 

Even if you do use the original, checking dimensions is only necessary if you feel it to be.  For example if you had a photo gallery people may want/need to upload large dimension images.

 

 

Pretty much, it all boils down to do you think it is necessary, and if so what do you feel is a reasonable dimension/size for user's images.  I personally haven't limited peoples image uploads beyond raw filesize in anything I have done recently.  Even if it's just for a profile photo or similar i usually give the user the ability to crop/edit their upload as necessary so I store the original un-altered file somewhere then make copies to use on the site where necessary.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.