Bug #67567 [NEW]: i cannot create the imagick() class and not access the functions.
From: periyasamy at opendesigns dot in
Operating system: windows 7 32-bit
PHP version: 5.5Git-2014-07-04 (Git)
Package: *Web Server problem
Bug Type: Bug
Bug description:i cannot create the imagick() class and not access the functions.
Description:
------------
---
From manual page: http://www.php.net/imagick.setresolution
---
I want to set the resolution for a the image.
Test script:
---------------
<html>
<body>
<form action="image.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
<?php
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"]["type"] == "image/png"))
&& in_array($extension, $allowedExts)) {
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] .
"<br>";
} else {
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . "
kB<br>";
echo "Temp file: " . $_FILES["file"]["tmp_name"] .
"<br>";
if (file_exists("images/" . $_FILES["file"]["name"])) {
echo $_FILES["file"]["name"] . " already exists. ";
} else {
move_uploaded_file($_FILES["file"]["tmp_name"],
"images/" . $_FILES["file"]["name"]);
$filename = "images/" . $_FILES["file"]["name"];
$image = $_FILES["file"]["name"];
$im = new Imagick($image);
$im->setResolution(144,144);
$im->readImage($image);
$percent = 0.5;
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;
// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight,
$width, $height);
$path = "images/upload/T".$image;
imagejpeg($thumb,$path);
imagedestroy($thumb);
//thumb
$target_width = $width * 1;
$target_height = $height * 1;
// Load
$thumb = imagecreatetruecolor($target_width, $target_height);
$source = imagecreatefromjpeg($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $target_width,
$target_height, $width, $height);
$path = "images/thumb/U".$image;
imagejpeg($thumb,$path);
imagedestroy($thumb);
}
}
} else {
echo "Invalid file";
}
?>
Expected result:
----------------
I want to set the resolution for a particular image.
Actual result:
--------------
not set the resolution only resize the image
--
Edit bug report at https://bugs.php.net/bug.php?id=67567&edit=1
--
Thread (2 messages)
- periyasamy at opendesigns dot in