Weet iemand hoe je een plaatje kan resizen zonder hem op te slaan.

Dus stel je hebt een link naar een plaatje:

http://www.google.nl/logo.jpg Dan laat ie gewoon een kleinere versie zien.

Ik vond dit op een website (http://icant.co.uk/articles/phpthumbnails/) maar hier moet je weer uploaden. En dat wil ik juist niet.

createthumb('pics/apple.jpg','thumbs/tn_apple.jpg',100,100);

Deze lijkt een beetje op wat ik wil... maar hij upload em wel.. :S

Alvast bedankt,

//EDIT

Owja deze had ik ook gevonden, maar hij doet niets... Want het weergeven werkt niet.

<?php
$source = "http://www.ebizz.nl/image.jpg";;

$size = getimagesize($source);
$width = $size[0];
$height = $size[1];
$source_img = imageCreateFromJPEG($source);

if ($width >= $height)
{
$final_width = 100; //Max width in px
$final_height = $height / $width * $width;
}
else
{
$final_height = 100; //Max height in px
$final_width = $width / $height * $height;
}

$new_img = imagecreatetruecolor($final_width, $final_height);
$target_pic = imageCopyResampled($new_img, $source_img, 0, 0, 0, 0,$final_width,$final_height,$width,$height);
?>
is het simpele width en height in html dat je in de <img src=""> moet plaatsen geen optie?
(idee van stefan voluit) zo dus:
<img src="link.html" width="200" height="100" border="0">

Succes..!
nou, als het plaatje dan kleiner is dan 200 width ... dan vergroot ie em :P das niet de bedoeling.
deze functie heb ik gemaakt

<?
function image($file, $max=100){
$exists = getimagesize($file);
if($exists){
list($width, $height, $type, $size) = $exists;
if($width > $max OR $height > $max){
if($width > $height){
$factor = $max / $width;
$_height = round($height * $factor);
$_width = $max;
} else {
$factor = $max / $height;
$_height = $max;
$_width = round($width * $factor);
}
size = 'width="'.$_width.'" height="'.$_height.'"';
}
return '<img src="'.$file.'" align="right" '.$size.' hspace="5" border="0">';
}else{
return false;
}
}
?>
@ Stijn, jou plaatje doet t niet in FF alleen in IE ;) In FF zie je alleen allemaal tekst
Oké hipska, dat ga ik even proberen .. :D
Ik mis wat Hipska... volhgens mij wat vars... ik pruts wel wat. werkt ie ook?

Hier het hele script.

<?php
include ('../safe.php');
$id = $_GET['id'];
?>
<link rel="stylesheet" href="../style.css" type="text/css">
<h1>Foto album bekijken.</h1>
<p>
<hr>
<p>
<center>
<table border="0">
<tr><th colspan="2">Foto bekijken:</th></tr>
<tr>
<td>
<?php
$sql1 = "SELECT * FROM fotoalbum WHERE id='$_GET[img]' AND user='$id'";
$query1 = mysql_query($sql1);
$rij1 = mysql_fetch_object($query1);
$file = htmlspecialchars($rij1->img);
$omschrijvingbig = htmlspecialchars($rij1->omschrijving);

if(isset($_GET[img])){
function image($file, $max=100){
$exists = getimagesize($file);
if($exists){
list($width, $height, $type, $size) = $exists;
if($width > $max OR $height > $max){
if($width > $height){
$factor = $max / $width;
$_height = round($height * $factor);
$_width = $max;
} else {
$factor = $max / $height;
$_height = $max;
$_width = round($width * $factor);
}
$size = 'width="'.$_width.'" height="'.$_height.'"';
}
return '<img src="'.$file.'" align="right" '.$size.' hspace="5" border="0">';
}else{
return false;
}
}
}
?>
</td><td></td>
</tr>
</table>
<p>
<table border="1" width="90%" >
<tr><th>Fotoalbum:</th></tr>
<?php
$query = mysql_query("SELECT * FROM fotoalbum WHERE user = '$id'") or die(mysql_error());
while($row = mysql_fetch_array($query)){
?>
<tr>
<td align="left"><a href="bekijken.php?id=<?php echo $id; ?>&img=<?php echo $row[id]; ?>"><img src="<?php echo $row[img]; ?>" alt="<?php echo $row[omschrijving]; ?>" width="160" border="0"></a></td>
</tr>
<?php
}
?>
</table>
</center>
Ik heb een oplossing, als de getimagesize groter is dan 400 .. dan zet ie bij de width 400 neer .. anders niks :D
Ik weet niet of het werkt maar <img src="plaatje.jpg" width="1%" height="1%" border="0"> dan word ie altijd kleiner

Reageren