Learning the internals
For the more curious minds there’s a way to learn ImageMagick commands and to know exactly what phMagick is doing
1 2 3 | $p = new phmagick('results/result.png', 'results/resize.jpg'); $p->resize(100,75); echo '<pre>',print_r ( $p->getLog() ) , '</pre>'; |
This will output what phMagick is doing as well as any ImageMagick error messages or information
Array
(
[0] => Array
(
[cmd] => convert -scale "100x75>" -quality 80 -strip "results/result.png" "results/resize.jpg"
[return] => 0
[output] => Array
(
)
)
)
Is there a way to add manual commands? When converting PDFs to JPG, my JPG is coming out looking like crap and is unreadable. In reading a few ImageMagick forums there are some commands I would like to try (like -density 400), but not sure how to use with your class without diving into your original code.
I ended up adding my own custom function and variable to the class:
class phmagick{
private $custom_cmd = ”;
….
public function setCustomCommand($cd){
$this->custom_cmd=$cd;
}
public function execute($cmd){
if ($this->custom_cmd) $cmd=”convert “.$this->custom_cmd.” “.str_replace(“convert “,”",$cmd); …
This seemed to work like a charm. This allowed me to execute this command:
$p->setCustomCommand(‘-density 400′);
$p->acquireFrame(‘file.pdf’,0);
$p->setCustomCommand(”);//reset custom command to blank in case future commands are run.
How can we determine, in PHP, whether the conversion/processing was successful? Thank you!
@Amir,
You can check if the new file is present
phMagick will throw an exception if something goes wrong