Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

johnhey

Efeitos em foto

Recommended Posts

Peço desculpas se o tópico não estiver no local certo.

 

Um dos sites que tenho possui a opção de inserir fotos, esta tudo a funcionar, o cliente cria o album e insere as fotos.

Só que primeiro ele me envia as fotos em cru e depois faço alguns efeitos no photoshop e reencaminho a ele para inseri-las, mais queria facilitar isso.

 

Gostaria de saber se em php existe alguma forma para fazer isso?

Ao inserir as fotos o proprio site antes de adicionar ao servidor mesclasse as fotos com os efeitos.

tipo assim.

 

faço uma imagem tipo com os efeitos e adiciono a foto do cliente por tras desta Imagem.

 

Exemplo:

 

Fotocliente + fototipo = fotoreal - guardar

 

Espero que tenham compreendido.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Boa Pessoal o que estou fazendo de errado?

 

fiz o seguinte código:

<?php
include "lib/WideImage.php";
$img = WideImage::load("imagens/teste.png");
$watermark = WideImage::load("imagens/fotoreal.png");

$new = $img->merge($watermark, 'right', 'bottom – 10', 100);
header('Content-Type: image/png');
echo $new;
file_put_contents("foto1.png", $new);
?>

no computador esta a funcionar na perfeição, mas quando faço upload do arquivo para o servidor não funciona.

 

se coloco www.meusite.pt/mesclar.php dá o seguinte erro:

 

Warning: file_get_contents(imagens/teste.png) [function.file-get-contents]: failed to open stream: No such file or directory in /htdocs/public/www/lib/WideImage.php on line 195

Warning: unpack() [function.unpack]: Type c: not enough input, need 1, have 0 in /htdocs/public/www/lib/vendor/de77/TGA.php on line 93

Fatal error: Uncaught exception 'WideImage_InvalidImageSourceException' with message 'File 'imagens/teste.png' appears to be an invalid image source.' in /htdocs/public/www/lib/WideImage.php:226 Stack trace: #0 [internal function]: WideImage::loadFromFile('imagens/teste.p...') #1 /htdocs/public/www/lib/WideImage.php(184): call_user_func(Array, 'imagens/teste.p...') #2 /htdocs/public/www/mesclar.php(3): WideImage::load('imagens/teste.p...') #3 {main} thrown in /htdocs/public/www/lib/WideImage.php on line 226

Compartilhar este post


Link para o post
Compartilhar em outros sites

Caminho inválido, passe o path absoluto do arquivo.


dirname (__FILE__);

ou

dirname (__DIR__);

http://php.net/manual/pt_BR/language.constants.predefined.php


http://php.net/manual/pt_BR/function.dirname.php

Compartilhar este post


Link para o post
Compartilhar em outros sites

Peço desculpas Williams Duarte, mas infelizmente ainda estou com dificuldade, ja vi no youtube uns videos sobre o assunto e ja tentei fazer mais da o mesmo erro.

 

fiz da seguinte forma:

 

<?php

 

$path = "/lib/WideImage.php";

$file = dirname($path)."/WideImage.php";

include $file;

 

$path1 = "/imagens/teste.png";

$file1 = dirname($path1)."/teste.png";

 

$file2 = dirname($path1)."/fotoreal.png";

 

$img = WideImage::load($file1);

$watermark = WideImage::load($file2);

 

$new = $img->merge($watermark, 'right', 'bottom – 10', 100);

header('Content-Type: image/png');

echo $new;

file_put_contents("imagens/foto1.png", $new);

?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Também fiz conforme o exemplo e da o mesmo erro.

 

<?php

 

/**

* @def (string) DS - Directory separator.

*/

define("lib","/",true);

 

/**

* @def (resource) BASE_PATH - get a base path.

*/

define('BASE_PATH',realpath(dirname(__FILE__)).lib,true);

 

include BASE_PATH.'lib/WideImage.php';

 

$path1 = "/imagens/teste.png";

$file1 = dirname($path1)."/teste.png";

 

$file2 = dirname($path1)."/fotoreal.png";

 

$img = WideImage::load($file1);

$watermark = WideImage::load($file2);

 

$new = $img->merge($watermark, 'right', 'bottom – 10', 100);

header('Content-Type: image/png');

echo $new;

file_put_contents("imagens/foto1.png", $new);

?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Cara seu problema é o caminho

 

verifica se este caminho está correto, para isso use a função abaixo

 

file_exists

<?php

$file = 'imagens/foto1.png';

if(file_exists($file)) {
  
	$new = $img->merge($watermark, 'right', 'bottom – 10', 100);
	header('Content-Type: image/png');
	echo $new;
	file_put_contents($file, $new);

} else {
	die('Caminho inválido');
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Copiou um script pronto que nem resposta teve, e ainda quer solução para ele?

Ai fica difícil!! :ph34r:


http://stackoverflow.com/questions/29284665/php-image-merge-api-not-working-in-codeigniter-rest-api

LFGIVYL.png

Compartilhar este post


Link para o post
Compartilhar em outros sites

consegui resolver de outra forma:

 

fica o código a funcionar.

<?php

// tutorial para inserir marca dagua
header('content-type: image/jpeg', 'content-type: image/png');
// carrega as imagens
$foto= imagecreatefromjpeg("imagens/teste.jpg"); // não esquecer de verificar o nome do arquivo
$marca=imagecreatefrompng("imagens/fotoreal.png"); // não esquecer de verificar o nome do arquivo

// pega as dimensoes da marca d'agua
$marca_larg=imagesx($marca);
$marca_alt= imagesy($marca);

// insere a marca na imagem
imagecopyresampled($foto,$marca,0,0,0,0,$marca_larg,$marca_alt,$marca_larg,$marca_alt);

// exibe a imagem
imagejpeg($foto,"",100);

?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.