WideImage仅适用于某些图像

时间:2016-05-06 14:06:49

标签: php thumbnails gd wideimage

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:异常   &#39; WideImage_InvalidImageSourceException&#39;与消息&#39;文件   &#39; / kunden /主页/ 33 / d582216481 / htdocs中/上载/下载/图像   .PNG&#39;似乎是无效的图片来源。&#39;在   /主页/ 33 / d582216481 / htdocs中/包括   /WideImage/WideImage.php:226堆栈跟踪:

     

0 /homepages/33/d582216481/htdocs/includes/phpThumb.php(12):

     

WideImage :: loadFromFile(&#39; / kunden / homepag ...&#39;)

     

1 /homepages/33/d582216481/htdocs/includes/addDownload.php(60):

     

make_thumb(&#39; / kunden / homepag ...&#39;,&#39; / kunden / homepag ...&#39;,100)

     

2 {main} Thumb Creation Started

有人可以解释一下,为什么它适用于某些图像,而某些图像则不适用?

<?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);

&GT;

Not working working

0 个答案:

没有答案