Object of class WebImage could not be converted to string
Bonjour,
Je viens de migrer un site vers php 5.3.11 et j'obtiens un message d'erreur Object of class WebImage could not be converted to string.
Voici la ligne qui génère cette erreur :
Code:
if ($this->resize && $this->$this->crop)
J'ai lu que depuis php 5.2, la conversion vers une chaine ne se fait plus implicitement. Mais voilà, je ne sais pas comment procéder. Si quelqu'un peut m'aider, ce serait très apprécié. Merci
Et voici le code complet de la fonction :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| function convert()
{
// Cannot trim when doing resize + crop
if ($this->resize && $this->$this->crop)
$this->trim = false;
$cmd = 'convert '.escapeshellarg($this->original_path); // Source image
if (!empty($this->crop))
{
// Crop this part
$cmd .= escapeshellcmd(' -crop '.$this->crop_width.'x'.$this->crop_height.$this->crop_xpos.$this->crop_ypos);
}
if ($this->resize)
{
// Resize image to fit this size
$cmd .= escapeshellcmd(' -resize '.$this->resize_width.'x'.$this->resize_height);
if($this->resize_noenlarge)
$cmd .= '\>';
}
if ($this->cropresize)
{
// Resize to minimally fit this size, and crop the rest
$cmd .= escapeshellcmd(' -resize '.$this->cropresize_resizewidth.'x'.$this->cropresize_resizeheight.' -gravity center -crop '.$this->cropresize_width.'x'.$this->cropresize_height.'+0+0');
}
if ($this->trim)
$cmd .= ' -trim + repage'; // Remove "blank" border of the image
if (!empty($this->filter))
$cmd .= ' -filter '.$this->filter; // Use a filter
if ($this->sharpen > 0)
$cmd .= ' -unsharp 0x'.$this->sharpen; // Use sharpening
if($this->quality >= 0)
$cmd .= ' -quality '.$this->quality; // Set quality
$cmd .= ' '.escapeshellarg($this->save_dir.$this->save_file); // Save to this file
$cmd .= ' && chmod 644 '.escapeshellarg($this->save_dir.$this->save_file); // Change access rights
$this->cmd = $cmd;
$res = exec($cmd, $this->output, $return_var);
return $return_var;
} |