php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67567 i cannot create the imagick() class and not access the functions.
Submitted: 2014-07-04 08:35 UTC Modified: 2014-07-04 10:13 UTC
From: periyasamy at opendesigns dot in Assigned:
Status: Not a bug Package: *Graphics related
PHP Version: 5.5Git-2014-07-04 (Git) OS: windows 7 32-bit
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: periyasamy at opendesigns dot in
New email:
PHP Version: OS:

 

 [2014-07-04 08:35 UTC] periyasamy at opendesigns dot in
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-04 10:13 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: *Web Server problem +Package: *Graphics related
 [2014-07-04 10:13 UTC] requinix@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Putting aside the fact that you give the wrong filename to imagick, which will throw an exception when it can't find the file, you don't actually USE imagick to do anything. All the work is done by GD.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 09:01:30 2024 UTC