Mailinglisten-Archive |
Sicher geht das verkleinern sowie Zoomen beispiel:
http://www.jazzascona.ch/hotel/asconazoomin.php3
solange Gif:
http://www.php.net/manual/function.imagecreatefromgif.php3
ist eben Gif um neu create zu machen.
<?php
Header( "Content-type: image/gif");
$bigmap=ImageCreateFromGif( "asconabig.gif"); file://jpg geht eben nicht
$image_out=ImageCreate(300,300);
$factor=3.75;
$posx=floor($x*$factor-100);
$posy=floor($y*$factor-48);
$copia=ImageCopyResized($image_out, $bigmap, 0, 0, $posx, $posy, 300, 300,
300, 300);
ImageGif($image_out);
ImageDestroy($bigmap);
ImageDestroy($image_out);
?>
oder dieses Script gut studieren:
<?
/*
* The thumbnail function uses the pnmscale program from
* the popular Netpbm image manipulation tools package
* to create a thumbnail of the given image. If a thumbnail
* already exists for the image, the function simply returns.
*/
cfunction thumbnail($filename) {
global $theight;
/* Define where to find the various external binaries we need
*/
$djpeg = "/usr/local/bin/djpeg"; /* decompresses a jpeg to ppm
*/
$cjpeg = "/usr/local/bin/cjpeg"; /* compreses a ppm to jpeg format
*/
$pnmscale = "/usr/local/netpbm/pnmscale"; /* scales a ppm image
*/
$giftopnm = "/usr/local/netpbm/giftopnm"; /* convert a gif to ppm
*/
$ppmtogif = "/usr/local/netpbm/ppmtogif"; /* convert a ppm to gif
*/
$ppmquant = "/usr/local/netpbm/ppmquant"; /* colour quantize a ppm
*/
$tdir = dirname($filename). "/thumbnails"; /* thumbnail directory
*/
if(!filetype($tdir)) {
if(!_(at)_mkdir($tdir,0777)) {
echo "Unable to create $tdir dir - check
permissions<br>\n";
return;
}
}
$tfile = $tdir. "/".basename($filename); /* thumbnail file
*/
if(!filesize($tfile)) {
if(ereg( "\.gif$",$filename)) { /* Look for .gif extension
*/
exec( "$giftopnm $filename | $pnmscale -height $theight ".
"| $ppmquant 256 | $ppmtogif -interlace > $tfile");
} elseif(ereg( "\.jpe?g",$filename)) { /* Look for .jpg or
.jpeg */
exec( "$djpeg $filename | $pnmscale -height $theight | ".
"$cjpeg -outfile $tfile");
} else { /* not a GIF or JPG file */
return( "");
}
}
return($tfile);
}
/* If the album variable isn't set, show the album list */
if(!$album) {
$title = "Photo Albums";
$page = "albums";
include "include/header.inc";
/* Get a list of the available albums */
$albums = mysql_query( "select filename,album,count(*) as
num_albums".
" from photos group by album");
echo "<table align=center>\n";
/* Loop through each album */
while($row=mysql_fetch_row($albums)) {
$row[1] = stripslashes($row[1]);
$thumb = thumbnail($row[0]);
if(strlen($thumb)) {
echo "<tr><td><a
href=\"$PHP_SELF?album=".urlencode($row[1]);
$size = getimagesize($thumb);
echo "\"><img src=\"$thumb\" border=0 $size[3]></a></td>";
echo " <td><font size=+1><b>".$row[1]. "</b></font><br>";
echo "$row[2] photos<br></td></tr>\n";
}
}
echo "</table>\n";
mysql_free_result($albums);
}
/* Ok, an album was selected, show the thumbnails for this album */
else {
$title = stripslashes($album);
$page = "thumbnails";
include "include/header.inc";
$pics = mysql_query( "select filename,text from photos where ".
"album='$album'");
$album=stripslashes($album);
echo "<center>\n";
while($row=mysql_fetch_row($pics)) {
if($photo==$row[0]) {
$desc=stripslashes($row[1]);
}
$thumb = thumbnail($row[0]);
if(strlen($thumb)) {
echo "<a href=\"$PHP_SELF?album=".urlencode($album);
$size = getimagesize($thumb);
echo "&photo=$row[0]\"><img src=$thumb border=0
$size[3]></a>\n";
}
flush(); /* Force web server to flush buffer */
}
echo "</center>\n";
/* If a picture was selected as well, show the picture */
if($photo) {
$size=getimagesize($photo);
echo "<center><img src=\"$photo\"
$size[3]><br>$desc</center>\n";
}
mysql_free_result($pics);
}
include "include/footer.inc";
?>
webadmin Ticino webcamera www.ti-news.ch
www.ppk.grossalp.ch
=============================================
----- Original Message -----
From: Christiane Schmidt-Köster <C.Schmidt-Koester_(at)_gmx.net>
To: <php_(at)_solix.wiso.Uni-Koeln.DE>
Sent: Saturday, November 27, 1999 8:33 AM
Subject: [php] Skalieren/Verkleinern von JPGs mit PHP (2.Versuch)
> hallo liste,
>
> ich versuchs einfach nochmal:
>
> vor einiger zeit gab es hier mal einen thread, über das
> skalieren/verkleinern von upgeloadeten JPG's.
>
> björn hatte damals die idee mit einem php-systemcall auf netpbm bzw.
> imagemagick, was auch sicher funktionieren würde. aber leider klappts bei
> mir mit der installation der beiden programme (oder wenigstens einem)
nicht.
> vermutlich, weil diverse paketabhängigkeiten bestehen und diese pakete
nicht
> vorhanden sind. ist übrigens nicht mein eigener server und ich hatte
> versucht auf meinem webspace eines der pakete ans laufen zu bringen ;-(
>
> nun meine frage: hat jemand eine alternative idee zum verkleinern von
jpeg's
> über php?
>
> ist es korrekt, dass man mit PHP und den image-funktionen zumindest GIFs
> verkleinern kann?
>
> christiane
>
>
>
> --
> ** Durchgehend geöffnet: http://www.php-center.de **
> Die PHP-Liste: mailto:php_(at)_infosoc.uni-koeln.de
> http://infosoc.uni-koeln.de/mailman/listinfo/php
php::bar PHP Wiki - Listenarchive