Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Find below php code to upload and crop image using GD library. You can save only one image name in database and other croped images will be access using the same name, but it should be stored in different-different directory as below: </p> <pre><code>&lt;?php function createThumb($upfile, $dstfile, $max_width, $max_height){ $size = getimagesize($upfile); $width = $size[0]; $height = $size[1]; $x_ratio = $max_width / $width; $y_ratio = $max_height / $height; if( ($width &lt;= $max_width) &amp;&amp; ($height &lt;= $max_height)) { $tn_width = $width; $tn_height = $height; } elseif (($x_ratio * $height) &lt; $max_height) { $tn_height = ceil($x_ratio * $height); $tn_width = $max_width; } else { $tn_width = ceil($y_ratio * $width); $tn_height = $max_height; } if($size['mime'] == "image/jpeg"){ $src = ImageCreateFromJpeg($upfile); $dst = ImageCreateTrueColor($tn_width, $tn_height); imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height,$width, $height); imageinterlace( $dst, true); ImageJpeg($dst, $dstfile, 100); } else if ($size['mime'] == "image/png"){ $src = ImageCreateFrompng($upfile); $dst = ImageCreateTrueColor($tn_width, $tn_height); imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height,$width, $height); Imagepng($dst, $dstfile); } else { $src = ImageCreateFromGif($upfile); $dst = ImageCreateTrueColor($tn_width, $tn_height); imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height,$width, $height); imagegif($dst, $dstfile); } } //usage if(isset($_FILES['upload_Image']['name']) &amp;&amp; $_FILES['upload_Image']['name']!=='') { $ext = substr($_FILES['upload_Image']['name'], strpos($_FILES['upload_Image']['name'],'.'), strlen($_FILES['upload_Image']['name'])-1); $imgNormal = time().$ext; $normalDestination = "Photos/Orignal/" . $imgNormal; $httpRootLarge = "Photos/Large/" . $imgNormal; $httpRootSmall = "Photos/Small/" . $imgNormal; $httpRootThumb = "Photos/Thumb/" . $imgNormal; move_uploaded_file($_FILES['upload_Image']['tmp_name'], $normalDestination); createThumb($normalDestination,$httpRootLarge,680,604); #For 604x604 Image createThumb($normalDestination,$httpRootSmall,500,300); #For 500x300 Image createThumb($normalDestination,$httpRootThumb,130,100); #For 130x100 Image } ?&gt; &lt;form action="" method="post" enctype="multipart/form-data"&gt; &lt;label for="file"&gt;Filename:&lt;/label&gt; &lt;input type="file" name="upload_Image" id="upload_Image" /&gt; &lt;br /&gt; &lt;input type="submit" name="submit" value="Submit" /&gt; &lt;/form&gt; </code></pre> <p>You need to store $imgNormal value in database only.</p> <p>for more reference click on below link:</p> <p><a href="http://pastebin.com/Ed2YHV6w" rel="nofollow">http://pastebin.com/Ed2YHV6w</a> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload