Jump to content

image resize


Amrita

Recommended Posts

Hi Everbody,

Iam new to this forum.

I have written a program to upload an image and resize the image based on the distance between the eyes. Iam posting the code below. Please let me know whether my logic is correct.Iam resizing it so that the distance between the pupils in all the resized images is 128.

Any Suggestions from your side would be of great help to me.

Thank you

Amrita

 

 

<?php

function resizeimage($filena,$val,$ed)

{

$filename = 'files/'.$filena;

$width = "";

$height = "";

$percent=$ed;

header('Content-type: image/jpeg');

list($width_orig, $height_orig) = getimagesize($filename);

$width=($width_orig*128)/$percent;

$height =(height_orig*width)/width_orig;

$image_p = imagecreatetruecolor($width, $height);

$image = imagecreatefromjpeg($filename);

imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);

imagejpeg($image_p, null, 100);

$pieces = explode(".", $filena);

$pieces[0];

$pieces[1];

$new_filename=$pieces[0]."_modi.".$pieces[1];

$image_path = $_SERVER["DOCUMENT_ROOT"]."/Amrita/files/".$new_filename;

imagejpeg($image_p,$image_path);

return $new_filename;

}

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/103214-image-resize/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.