Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to resize an image like facebook cover
    primarykey
    data
    text
    <p>What basically I am trying to do is to create a cover page for my personal website, just like facebook. Basically I am after the same layout of the cover as on facebook, so that user can get the same result while using the same cover on my site as well as on facebook.</p> <p>The part I am stucked at is the "Drag image to position cover" thing. The Facebook uses some algorithm to convert the cover image size to something different during dragging thing. For example, if the original image dimensions are 920x720, the dimensions of same image while it is on facebook setting-cover page(drag image to position cover thing), the dimensions of the image are 851x638. </p> <p>I just wanted to know what algorithm facebook uses to set the image dimensions(from 720 to 638)</p> <p><strong>NOTE: The cover has to be the pixel perfect</strong></p> <p>I know that the cover dimension of facebook is 851x315, so here is what I am doing:</p> <pre><code> //$x = X origin cordinate variable obtained by dragging image //$y = Y origin cordinate variable obtained by dragging image list($k, $l) = getimagesize($src); // $src == image source //$w = Needs to be calculated //$h = Needs to be calculated $img_r = imagecreatefromjpeg($src); $dst_r = ImageCreateTrueColor( 854,316 ); imagecopyresampled($dst_r,$img_r,0,0,$x,$y,$w,$h,$k,$l); imagejpeg($dst_r,$src,$jpeg_quality); $img_name = writeToImage($src, $des); //writeToImage() is just a demo function created by me to do some other things with them which do not affect this part of code echo $img_name; </code></pre> <p>I need to figure out how facebook calculates the new dimension of the image from previous one. Is it dependent of the actual(original) size of the image or is it dependent on some other factors?</p>
    singulars
    1. This table or related slice is empty.
    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. 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