1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-07-15 13:56:30 +02:00

add debug for test

This commit is contained in:
Mikael Roos
2016-08-08 16:48:23 +02:00
parent 7677fc772f
commit b5de49d601

View File

@ -941,28 +941,17 @@ class CImage
is_readable($file) is_readable($file)
or $this->raiseError('Image file does not exist.'); or $this->raiseError('Image file does not exist.');
return $this->getImageDetails();
}
/**
* Get image details.
*
* @return $this
* @throws Exception
*/
protected function getImageDetails()
{
$info = list($this->width, $this->height, $this->fileType) = getimagesize($this->pathToImage); $info = list($this->width, $this->height, $this->fileType) = getimagesize($this->pathToImage);
if (empty($info)) { if (empty($info)) {
// To support webp // To support webp
$this->fileType = false; $this->fileType = false;
if (function_exists("exif_imagetype")) { if (function_exists("exif_imagetype")) {
$this->fileType = exif_imagetype($this->pathToImage); $this->fileType = exif_imagetype($file);
if ($this->fileType === false) { if ($this->fileType === false) {
if (function_exists("imagecreatefromwebp")) { if (function_exists("imagecreatefromwebp")) {
$webp = imagecreatefromwebp($this->pathToImage); die("before create webp " . $file);
$webp = imagecreatefromwebp($file);
die("after create webp " . $file);
if ($webp !== false) { if ($webp !== false) {
$this->width = imagesx($webp); $this->width = imagesx($webp);
$this->height = imagesy($webp); $this->height = imagesy($webp);
@ -980,7 +969,7 @@ class CImage
if ($this->verbose) { if ($this->verbose) {
$this->log("Loading image details for: {$file}"); $this->log("Loading image details for: {$file}");
$this->log(" Image width x height (type): {$this->width} x {$this->height} ({$this->fileType})."); $this->log(" Image width x height (type): {$this->width} x {$this->height} ({$this->fileType}).");
$this->log(" Image filesize: " . filesize($this->pathToImage) . " bytes."); $this->log(" Image filesize: " . filesize($file) . " bytes.");
$this->log(" Image mimetype: " . $this->getMimeType()); $this->log(" Image mimetype: " . $this->getMimeType());
} }
@ -1517,8 +1506,7 @@ class CImage
$this->setSource($src, $dir); $this->setSource($src, $dir);
} }
is_readable($this->pathToImage) $this->loadImageDetails();
or $this->raiseError('Image file does not exist.');
$imageAsString = file_get_contents($this->pathToImage); $imageAsString = file_get_contents($this->pathToImage);
$this->image = imagecreatefromstring($imageAsString); $this->image = imagecreatefromstring($imageAsString);
@ -1526,9 +1514,6 @@ class CImage
throw new Exception("Could not load image."); throw new Exception("Could not load image.");
} }
$this->getImageDetails();
/* Removed v0.7.7 /* Removed v0.7.7
if (image_type_to_mime_type($this->fileType) == 'image/png') { if (image_type_to_mime_type($this->fileType) == 'image/png') {
$type = $this->getPngType(); $type = $this->getPngType();