I am working on a membership site in which people can upload a company logo or personal photo.
However I want to display the image in different sizes. Are there any techniques I can use to display different images in same orientation and scale?
That sounds a bit contradictory, but anyhow ... you can set the width and height of images with CSS or even HTML, or you can set up the site with PHP to allow users to resize, crop and do other edits to images while they are uploading.
you can decide the size of the images that wont change and stay the same size, you can ask for the up-loaders to use the size that will be correct, or you can limit the size of the uploaded image to a fix size.
Thanks so can I resize any image orientation so that it resizes properly without distorting?
not exactly but you can write some sentence that say: please upload image of size:x and size:y. and write the minimum size you want and max.
and in css put the fixed size you want!
But wont that inconvene the user?
Can PHP resize an image upon upload?
OK, I think what is being said is that CSS and PHP are good.. but they can break the laws of physics.
IF your user upload somethings that is not the right aspect ratio.. to what you want... there will always be either some cropping or some distortion ( this happens even if a human is doing the image manipulation) So your options are:
1) ask the user to upload photos that are the correct size, or at least right aspect ratio.
2) Allow the user to crop/resize the uploaded image so that it is to his liking BUT that it also fits the aspect ratio necessary
3) scale the image using CSS knowing there will be some distortions of the images if they arent the correct aspect ratio.. and you may be wasting bandwith by loading unnecessarily large images.
4) use PHP to scale the images to size knowing there will be some distortions of the images if they arent the correct aspect ratio.
5) use PHP to crop the images knowing you may produce odd or unflattering crops.
What techniques do social networking sites such as Facebook or LinkedIn use? Or business directories in which people can add there own images.
You can use "cropnail" - where I crop the image from the center and resize it to requested thumbnail size.
As long as your object is in the center, you will neither lose ratio nor lose the object.
Link: class.cropnail.inc.php: http://smarty-framework.googlecode.com/svn/trunk/library/classes/sanjaal/class.cropnail.inc.php
$cropnail = new cropnail(100, 200); # your target dimension
$cropnail->resize($original_image_filename, $cropnail_image_filename, 0);
This works irrespective of the dimension of your original image.
I mean to say: You can get a vertical cropnail from a horizontally oriented image.
You can have a 100x200 thumbnail from an image of 800x400 (see the changes in ratio).
And you still prevent the image being distorted.
This is not a normal way of creating thumbnails, but it works for me, hope for you too.
This topic is now closed. New replies are no longer allowed.