<?php
 class phMagick_convert{ function convert(phmagick $p){ $cmd = $p->getBinary('convert'); $cmd .= ' -quality ' . $p->getImageQuality(); $cmd .= ' "' . $p->getSource() .'"  "'. $p->getDestination().'"'; $p->execute($cmd); $p->setSource($p->getDestination()); $p->setHistory($p->getDestination()); return $p ; } function save(phmagick $p){ return $p->convert($p); } function toWebp(phmagick $p, $quality = null){ $destination = $p->getDestination(); if (strtolower(pathinfo($destination, PATHINFO_EXTENSION)) !== 'webp') { $destination = $destination . '.webp'; $p->setDestination($destination); } if ($quality !== null) { $originalQuality = $p->getImageQuality(); $p->setImageQuality($quality); $result = $p->convert($p); $p->setImageQuality($originalQuality); return $result; } return $p->convert($p); } } ?>
