Ciao, allora errori non escono solo che quando prepara tante immagini alcune hanno quel problema. Gli errori sono abilitati ecc.. forse aumentanto il memory limit potrebbe migliorare?? Ora provo e provo a guardare anche il log...
Intanto ti incollo le parti interessanti della classe tante volte potesse servire:
Codice PHP:
public function __construct($idmovimentofoto=false,$ritaglia=false){
if (!$idmovimentofoto) {
return;
}
$this->id = $idmovimentofoto;
$cartella_pictures = realpath(dirname(__FILE__) . "/../../public/gallery/picture").$this->sotto_cartella;
$nomefile = $idmovimentofoto.".jpg";
$this->file = $cartella_pictures.$nomefile;
if (!file_exists($this->file)) {
$sql = "
SELECT
foto_originale
FROM movimentofoto
WHERE idmovimentofoto = '$idmovimentofoto'
";
$qry = mysql_query($sql);
$nrec = mysql_num_rows($qry);
if ($qry AND $nrec) {
$row = mysql_fetch_array($qry);
$this->foto_originale = $row["foto_originale"];
file_put_contents($this->file,$this->foto_originale);
}
}
// echo "ok=".$this->is_ok()."
";
if (!$this->is_ok()) {
if ($ritaglia) {
$this->ritaglia();
}
$this->ridimensiona();
}
}
public function ridimensiona(){
$source = imagecreatefromjpeg($this->file);
if ($this->is_orizzontale()) {
$new_width = intval($this->max_width);
$new_height = intval($new_width * $this->height() / $this->width());
}else{
$new_height = intval($this->max_height);
$new_width = intval($new_height * $this->width() / $this->height());
}
$dest = imagecreatetruecolor($new_width, $new_height);
$img = imagecopyresampled($dest, $source, 0, 0, 0, 0, $new_width,$new_height, $this->width(), $this->height());
imagejpeg($dest, $this->file, 60);
$this->get_proprieta(true);
}
public function ritaglia(){
$source = imagecreatefromjpeg($this->file);
if ($this->is_orizzontale()){
$cornice = ($this->height()/10);
$new_width = intval($this->height()-$cornice-$cornice);
$new_height = $new_width;
$x = intval(($this->width()-$new_width)/2);
$y = $cornice;
}else{
$cornice = ($this->width()/10);
$new_height = intval($this->width()-$cornice-$cornice);
$new_width = $new_height;
$x = $cornice;
$y = intval(($this->height()-$new_height)/2);
}
$dest = imagecreatetruecolor($new_width, $new_height);
$img = imagecopyresampled($dest, $source, 0, 0, $x, $y, $new_width,$new_height, $new_width,$new_height);
imagejpeg($dest, $this->file, 60);
$this->_proprieta = getimagesize($this->file);
}