WideImage は一部の画像でのみ機能します。画像のファイルタイプとサイズが同じであるため、理由がわかりません。
これが私のコードです
<?php
error_reporting(E_ALL);
include 'WideImage/WideImage.php';
function make_thumb($src, $dest, $desired_width) {
try {
WideImage::loadFromFile($src)->resize($desired_width, 50)->saveToFile($dest);
}
catch (Exception $e) {
echo 'EXCEPTION: '.$e;
}
}
?>
関数呼び出し
echo 'Thumb Creation Started';
make_thumb($filename, $thumbname, 100);
echo 'Thumb Creation Finished';
次のエラーが表示されます。
編集: このエラーは、firebug でデータを再送信した場合にのみ発生します。最初はエラーは表示されません。
Thumb Creation StartedEXCEPTION: 例外 'WideImage_InvalidImageSourceException' とメッセージ 'ファイル '/kunden/homepages/33/d582216481/htdocs/uploads/downloads/image .png' が無効な画像ソースのようです' /homepages/33/d582216481/htdocs/includes /WideImage/WideImage.php:226 スタック トレース:
0 /homepages/33/d582216481/htdocs/includes/phpThumb.php(12):
WideImage::loadFromFile(' /kunden/homepag...')
1 /homepages/33/d582216481/htdocs/includes/addDownload.php(60):
make_thumb('/くんでん/homepag ...', '/くんでん/homepag...', 100)
2 {main}Thumb の作成を開始しました
なぜ一部の画像で機能し、一部の画像では機能しないのか、誰か説明できますか??
<?php
error_reporting(E_ALL);
// Basic Conf
require_once ('basic_config.php');
// PHP Thumb
require_once ('phpThumb.php');
// DB INIT
require_once ($full_url.'includes/db.php');
// GET DATA FROM POST
$pid = $_POST['downloadProdukt'];
$downloadBezeichnung = $_POST['downloadBezeichnung'];
$downloadDatei = str_replace(' ', '_', $_FILES['downloadDatei']['name']);
$downloadKategorie = $_POST['downloadKategorie'];
$downloadSize = $_FILES['downloadDatei']['size'];
// GET Image adjustments
$image_info = getimagesize($_FILES["downloadDatei"]["tmp_name"]);
$image_width = $image_info[0];
$image_height = $image_info[1];
// GET FOLDER OF THE PRODUCT
$cols = Array ("PID","OrdnerName");
$db->where ('PID', $pid);
$produkte = $db->get ("produkt", null, $cols);
if ($db->count > 0){
foreach ($produkte as $produkt) {
$uploadFolder = $produkt['OrdnerName'];
}
}
// FILE
$filePath = $upload_url . $uploadFolder . "downloads/";
$rel_file_path = $uploadFolder . "downloads/";
$filename = $filePath . $downloadDatei;
$thumbname = $filePath . "thumb_" . $downloadDatei;
// Falls Ordner nicht existiert erstelle neu
if (!file_exists($filePath)) {
mkdir($filePath, 0777, true);
}
// Move file to Dir
if (move_uploaded_file($_FILES['downloadDatei']['tmp_name'], $filename)) {
//echo "Original Datei erfolgreich hochgeladen.\n";
} else {
echo "Möglicherweise eine Dateiupload-Attacke!\n";
}
// IF Image --> Generate Thumb
if (
// Wenn dateityp BILD
$_FILES['downloadDatei']['type'] == 'image/jpeg' OR
$_FILES['downloadDatei']['type'] == 'image/png' OR
$_FILES['downloadDatei']['type'] == 'image/gif'
){
echo 'Thumb Creation Started';
make_thumb($filename, $thumbname, 100);
$thumbname = "thumb_" . $downloadDatei;
echo 'Thumb Creation Finished';
} else {
$thumbname = null;
echo 'Kein Thumb';
}
// EXECUTE QUERY
$data = Array ("PID" => $pid,
'DownloadBez' => $downloadBezeichnung,
'DownloadKat' => $downloadKategorie,
'DownloadDatei' => $downloadDatei,
'DownloadOrdner' => $rel_file_path,
'DownloadSize' => $downloadSize,
'DownloadThumb' => $thumbname
);
$id = $db->insert ('downloads', $data);
?>