Mailinglisten-Archive |
Hallo Liste,
ich lade ein Bild per Online-Formular auf den Server.
Kopiere das Bild dann per copy(PARAMETER).
Wenn ich dann von dem kopierten .gif-Bild (Created in Gimp < 2.0) den
Pfad mit folgendem Aufruf
----- Start Source
$sourcefile =
PM_ENV_absolute_root.PM_ENV_relative_root."pics/termine_content/".$_FILES['image_one']['name'];
$targetfile =
PM_ENV_absolute_root.PM_ENV_relative_root."pics/termine_content/".$_FILES['image_one']['name'];
createJPGThumb($sourcefile, $targetfile, 250, 500,
$_FILES['image_one']['type']);
----- End Source
in die nachfolgende Funktion übergebe, erhalte ich immer folgende
Fehlermeldung
Warning: imagecreatefromgif():
'/home/michael/www/meineinkaufstipp.de/cms/pics/termine_content/MarioBart.gif'
is not a valid GIF file in
/home/michael/www/meineinkaufstipp.de/cms/lib/lib.meineinkaufstipp.inc.php
on line 1218
In Zeile 1218 wird nur die Funktion imagecreatedfromgif($sfile) aufgerufen.
Das Bild ist in dem richtigen Verzeichnis, weiterhin kann ich das Bild
per Netscape und Gimp jeweils öffnen.
Die Rechte stimmen auch. Was mache ich falsch?
Wo könnte der Fehler liegen? Ich weiss nicht mehr weiter. Habe schon
alles überprüft.
Wenn ich das gleiche mache, mit einer .jpg-Datei, dann funktioniert das
alles ordnungsgemäß.
Übrigens ist es vollkommen korrekt, dass ich alle Formate in das
.jpg-Format konvertiere.
Viele Grüße
Michael
PS: phpinfo() spuckt folgendes aus:
GD Support enabled
GD Version bundled (2.0.15 compatible)
FreeType Support enabled
FreeType Linkage with freetype
T1Lib Support enabled
GIF Read Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled
PPS: Hier noch die Funktion zum konvertieren.
----- Start Source Function
function createJPGThumb($sfile,$dfile, $maxWidth, $maxHeight, $imagetype)
{
// the passed variables are string filenames, the source and the
destination
global $maxwidth,$maxheight;
switch($imagetype) {
case 'image/gif':
$simg = imagecreatefromgif($sfile);
$image = 1;
break;
case 'image/jpeg':
$simg = imagecreatefromjpeg($sfile);
$image = 1;
break;
case 'image/png':
$simg = imagecreatefrompng($sfile);
$image = 1;
break;
}
if ($image == 1) {
$currwidth=imagesx($simg);
$currheight=imagesy($simg);
$newwidth = $currwidth;
$newheight = $currheight;
if ( $currwidth > $maxWidth ){
# image-width
$faktor = $currheight / $currwidth;
$newwidth = intval($maxWidth);
$newheight = intval($maxWidth * $faktor);
}
if( $currheight > $maxHeight ){
# image-height
$faktor = $currwidth / $currheight;
$newwidth = intval($maxHeight * $faktor);
$newheight = intval($maxHeight);
}
if ( $currwidth > $maxWidth ){
# image-width
$faktor = $currheight / $currwidth;
$newwidth = intval($maxWidth);
$newheight = intval($maxWidth * $faktor);
}
//create the resource img for the thumbnail
$dimg = imagecreate($newwidth, $newheight);
//convert truecolor image resource to palette image resource (so
we can count the colors...)
imagetruecolortopalette($simg, false, 256);
$palsize = ImageColorsTotal($simg);
for ($i = 0; $i<$palsize; $i++){
$colors = ImageColorsForIndex($simg, $i);
ImageColorAllocate($dimg, $colors['red'], $colors['green'],
$colors['blue']);
}
imagecopyresized($dimg, $simg, 0, 0, 0, 0, $newwidth,
$newheight, $currwidth, $currheight);
#save all files in format .jpg
$simg = imagejpeg($dimg,$dfile);
ImageDestroy($simg);
ImageDestroy($dimg);
}
}
----- End Source
php::bar PHP Wiki - Listenarchive