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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Pull Requests

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: Thu Dec 26 10:01:29 2024 UTC