public function recuperarImagem($id_imagem){ $query ="SELECT tbl_prova_pergunta_imagem.imagem AS imagem, tbl_prova_pergunta_imagem.prova_pergunta AS pergunta, tbl_prova_pergunta_imagem.descricao AS descricao, tbl_prova_pergunta_imagem.path AS path, tbl_prova_pergunta_imagem.thumb AS thumb FROM tbl_prova_pergunta_imagem WHERE tbl_prova_pergunta_imagem.imagem = ".$id_imagem; $banco = $this->getBancoDados(); $imagem = NULL; $retorno = $banco->executaSQL($query); if($retorno != NULL) { if ($banco->numRows($retorno) == 0){ throw new Exception("Nenhuma imagem encontrado.",0); } while($linha = $banco->fetchArray($retorno)) { $imagem = new Imagem(); $imagem->setId($linha['imagem']); $imagem->setPergunta($linha["pergunta"]); $imagem->setDescricao($linha["descricao"]); $imagem->setPath($linha["path"]); $imagem->setThumb($linha["thumb"]); } return $imagem; } else { throw new Exception("Erro ao recuperar Imagem ($query)"); } }
$obj_imagem->setPergunta($perg->getId()); $obj_imagem->setDescricao(''); $path_imagem = "perguntas/imagens/"; $path_thumb = "perguntas/imagens/"; #Resize $handle->image_resize = true; $handle->image_ratio_y = true; $handle->image_x = 640; $handle->file_name_body_add = "_".$perg->getId(); $handle->Process($path_imagem); if ($handle->processed) { $path_imagem = $handle->file_dst_pathname; $obj_imagem->setPath($path_imagem); } else { throw new Exception("Erro no UPLOAD da imagem: ".$handle->error,0); } #Thumb $handle->image_resize = true; $handle->image_ratio_y = true; $handle->image_x = 100; $handle->image_contrast = 10; $handle->jpeg_quality = 70; $handle->file_name_body_add = "_".$perg->getId()."_thumb"; $handle->Process($path_thumb); if ($handle->processed) { $path_thumb = $handle->file_dst_pathname;