• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Thumbnails erstellen

Status
Für weitere Antworten geschlossen.
A

Alti

Guest
Hallo.
Ich möchte etwas sehr simples machen, finde aber nur sehr kompliziertes um das zu lösen.
Ich möchte von einem 600x450px großes JPG Bild ein Thumbnail in der Größe von 120x90 in einem gewünschten Ordner erstellen.
Nur wenn ich es mitimagecopyresampled versuche kommt es nur verzogen herraus.
Ich habe im Internet folgendes Script gefunden, aber auch damit kann ich nicht wirklich was anfangen:
PHP:
<?php
function easyResize($img_sourse, $save_to, $quality, $width, $str) {
$size = GetImageSize($img_sourse);
   $im_in = ImageCreateFromJPEG($img_sourse);
  
   $new_height = ($width * $size[1]) / $size[0]; // Generate new height for image
   $im_out = imagecreatetruecolor($width, $new_height);
  
   ImageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width, $new_height, $size[0], $size[1]);
      
   #Find X & Y for note
   $X_var = ImageSX($im_out);
   $X_var = $X_var - 130;
   $Y_var = ImageSY($im_out);
   $Y_var = $Y_var - 25;

   #Color
   $white = ImageColorAllocate($im_out, 0, 0, 0);
  
   #Add note(simple: site address)
   ImageString($im_out,2,$X_var,$Y_var,$str,$white);

   ImageJPEG($im_out, $save_to, $quality); // Create image
   ImageDestroy($im_in);
   ImageDestroy($im_out);
}
// $str -  Inscription on the image;
//ab hier hab ich es hinzugefügt.
easyResize('images/bla.jpg', 'images/thumbnails_tn_bla.jpg', 100, 120, 1);
?>
Könnte mir jemand damit helfen?

MFG Alti
 
So wie ich das verstehe sollte dir das hier helfen:
Note: There is a problem due to palette image limitations (255+1 colors). Resampling or filtering an image commonly needs more colors than 255, a kind of approximation is used to calculate the new resampled pixel and its color. With a palette image we try to allocate a new color, if that failed, we choose the closest (in theory) computed color. This is not always the closest visual color. That may produce a weird result, like blank (or visually blank) images. To skip this problem, please use a truecolor image as a destination image, such as one created by imagecreatetruecolor().
Quelle: http://de3.php.net/manual/en/function.imagecopyresampled.php
 
War glaubh ich im Manual entweder bei imagecopyresized
oder imagecopyresampled
 
Status
Für weitere Antworten geschlossen.
Zurück
Oben