Jump to content

creating a thumbnail


contra10

Recommended Posts

im trying to create a thumbnal version of images that are in my directory but i can't seem to get it to work heres my coding

 

<?php
$im = imagecreatefromjpeg("http://localhost/toronto/image.jpg");

$x = imagesx($im); 
$y = imagesy($im); 


$desired_width = 60; 
$desired_height = $y * ($desired_width/$x); 


$new = imagecreatetruecolor($desired_width, $desired_height); 


imagecopyresampled($new, $im, 0, 0, 0, 0, $desired_width, $desired_height, $x, $y);

imagedestroy($im); 

echo "<div style='width: 100%; padding: 3px; border: 1px solid #000; background-color: green;'>" . imagejpeg($new, null, 85)  . "</div>";
?>

Link to comment
https://forums.phpfreaks.com/topic/160029-creating-a-thumbnail/
Share on other sites

i still get the symbols not the actual image

 

 

<?php
$im = imagecreatefromjpeg("image.jpg");

$x = imagesx($im); 
$y = imagesy($im); 


$desired_width = 60; 
$desired_height = $y * ($desired_width/$x); 


$new = imagecreatetruecolor($desired_width, $desired_height);


imagecopyresampled($new, $im, 0, 0, 0, 0, $desired_width, $desired_height, $x, $y);

imagedestroy($im); 

echo "<div style='width: 100%; padding: 3px; border: 1px solid #000; background-color: green;'>" . imagejpeg($new, null, 85)  . "</div>";
?>

Link to comment
https://forums.phpfreaks.com/topic/160029-creating-a-thumbnail/#findComment-844217
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.