justlukeyou — 2012-07-21T10:34:00-04:00 — #1
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?
ralphm — 2012-07-22T07:21:53-04:00 — #2
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.
canabatz — 2012-08-13T04:27:01-04:00 — #3
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.
justlukeyou — 2012-08-13T08:02:13-04:00 — #4
Thanks so can I resize any image orientation so that it resizes properly without distorting?
canabatz — 2012-08-13T08:15:18-04:00 — #5
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!
justlukeyou — 2012-08-13T15:23:30-04:00 — #6
But wont that inconvene the user?
Can PHP resize an image upon upload?
dresden_phoenix — 2012-08-13T16:27:56-04:00 — #7
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.
justlukeyou — 2012-08-13T16:36:02-04:00 — #8
What techniques do social networking sites such as Facebook or LinkedIn use? Or business directories in which people can add there own images.
bimalpoudel — 2012-08-16T06:19:22-04:00 — #9
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.