TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sheryl Roger
NA
11
2.3k
create thumbnail from images in PHP
May 28 2015 2:53 AM
if(preg_match('/[.](jpg)$/', $filename)) {
$im = imagecreatefromjpeg($file . $filename);
} else if (preg_match('/[.](gif)$/', $filename)) {
$im = imagecreatefromgif($file . $filename);
} else if (preg_match('/[.](png)$/', $filename)) {
$im = imagecreatefrompng($file . $filename);
}
$ox = imagesx($im);
$oy = imagesy($im);
$nx = $final_width_of_image;
$ny = floor($oy * ($final_width_of_image / $ox));
$nm = imagecreatetruecolor($nx, $ny);
imagecopyresized($nm, $im, 0,0,0,0,$nx,$ny,$ox,$oy);
imagejpeg($nm, $thumnailDir . $filename,100);
$tn = '<img src="' . $thumnailDir . $filename . '" alt="image" />';
$tn .= '<br />Congratulations. Your file has been successfully uploaded, and a thumbnail has been created.';
echo $tn;
here is the code m using for creating a thumbnail image... but it returns me an image of 0 bytes... can any one help me with this where I am making mistake?
Reply
Answers (
1
)
How to pass variables between php scripts?
how to insert data into two table using in php mysql