Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
Hi, I'm trying to do some fun stuff with databound forms and img upload. The user should be able to upload an image this image will be croped and merged with an other image nearly like a watermark. The merged image should be only visible to the user who created it with the option to download it.

below my template code

Code: Select all
<cms:template title='ImgUpload' clonable='1'>
    <cms:editable name='text' required='1' type='text' />
   <cms:editable name='img' required='0' allowed_ext='jpg, jpeg, png, gif'
max_size='1024' type='securefile' show_preview='1'
                  width='233'
                  height='111'
                  crop='1'
                  show_preview='1'
                  preview_width='100'/>
</cms:template>


the following will appear in the <cms:if k_success > [code here]</cms:if> part of the databound form.
Code: Select all
<cms:pages masterpage="index.php" limit='1'>
<cms:show_securefile 'img' >
<cms:php>
$logo_file = "<cms:cloak_url link=file_id />";
$image_file = "schachtel.jpg";
$targetfile = "img2.jpg";
$photo = imagecreatefromjpeg($image_file);
$fotoW = imagesx($photo);
$fotoH = imagesy($photo);
$logoImage = imagecreatefromjpeg($logo_file);
$logoW = imagesx($logoImage);
$logoH = imagesy($logoImage);
$photoFrame = imagecreatetruecolor($fotoW,$fotoH);
$dest_x = $fotoW - 350;
$dest_y = $fotoH - 135;
imagecopyresampled($photoFrame, $photo, 0, 0, 0, 0, $fotoW, $fotoH, $fotoW, $fotoH);
imagecopy($photoFrame, $logoImage, $dest_x, $dest_y, 0, 0, $logoW, $logoH);
imagejpeg($photoFrame, $targetfile);
echo '<img src="'.$targetfile.'" />';
</cms:php>
</cms:show_securefile>
</cms:pages>


So with the pages tag I get only the latest entry which should be the one from the user who created the image a second before. I also want to include the option to fill in text which should be merged with the image but the php script I found is only for images.

Anyway, the $logo_file = "<cms:cloak_url link=file_id />"; line is not working - what do I wrong here?

Thank you very much
Is it not possible to create the link to the file with secure_file in my case?
Hi,

The cms:cloak_url tag returns a URL (as opposed to the file's physical path) so this will work *only* if your server has fopen wrappers enabled (Google this if unsure).

As a test, please explicitly specify the URL of an image on your server (e.g. http://www.yourserver.com/test.jpg) as the $logo_file and see if it works.
3 posts Page 1 of 1