Author Topic: watermark when showing pic  (Read 54432 times)

0 Members and 1 Guest are viewing this topic.

Offline okram

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: watermark when showing pic
« Reply #30 on: September 14, 2005, 01:46:06 AM »
well i think i should remove this lines from the watermark.php

Code: [Select]
if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row)
{
  die("No permission");
}

in that way it workks correctly..... id it good?

thanks

Rather than removing it, if you replace it

with :

Code: [Select]

if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row) {

show_error_page($lang['no_permission']);

} ###### End of if statement.


Will it work ? ;)

As for this line :

Quote

$types = array(1 => "gif", 2 => "jpeg", 3 => "png");


it could always be

replaced with :

Code: [Select]

$types = str_replace(",",", ",$config['allowed_mediatypes']);


;)

As for this one :

Quote

if (!$im2 = @$image_create_handle($image))
  {
    die("Error opening $image!");
  }


replace with :

Code: [Select]

if (!$im2 = @$image_create_handle($image)) {

show_error_page($lang['no_image_found']);

} ###### End of if statement.


;)

well... what does exactly do the -> show_error_page() <- function?

TheOracle

  • Guest
Re: watermark when showing pic
« Reply #31 on: September 14, 2005, 01:48:17 AM »
Quote

well... what does exactly do the -> show_error_page() <- function?


It returns, in this case, the ' no permission ' page by keeping the site layout as it should. Otherwise, it will return a restricted message with a white page. ;)

Offline impss

  • Sr. Member
  • ****
  • Posts: 382
    • View Profile
    • Cusstom.net
Re: watermark when showing pic
« Reply #32 on: September 14, 2005, 01:50:22 AM »
If anyone is Interested this is the php file I use to add text to a image on the fly

Code: [Select]
<?php
//=========== change the text to display in the image
$text 'YOURTEXT';
$imgfile$_GET['get_image'];
$font 'arial.ttf';
$ext=substr($imgfile,-3);
$ext=strtolower($ext);

if(
$ext=="jpg" || $ext=="jpe"$im=@imagecreatefromjpeg("$imgfile");
elseif (
$ext=="gif"$im=@imagecreatefromgif("$imgfile"); 
else {print 
"Unknown image format"; exit;}

 if (!
$im) { /* See if it failed */
 
      $im ImageCreate (15030); /* Create a blank image */
 
      $bgc ImageColorAllocate ($im255255255);
 
      $tc  ImageColorAllocate ($im000);
 
      ImageFilledRectangle ($im0015030$bgc); 
 
      /* Output an errmsg */
 
      ImageString($im155"Error loading $imgfile"$tc); 
return $im;
 
  }

$x=imagesx($im);
$y=imagesy($im);
$fontsize=$x/40;
$fontsize=floor($fontsize);
if(
$fontsize<10$fontsize=10;

$white imagecolorallocate($im255255255);
$black imagecolorallocate($im000);

imagettftext($im$fontsize012$fontsize+8$black$font$text);
imagettftext($im$fontsize010$fontsize+6$white$font$text);

if(
$ext=="gif"
{
header("Content-type: image/gif");
imageGIF($im);
}
else
{
header("Content-type: image/jpeg");
imagejpeg($im);

}
imagedetroy($im);
?>

TheOracle

  • Guest
Re: watermark when showing pic
« Reply #33 on: September 14, 2005, 01:52:33 AM »
Hum ... are these functions intended to be used as part of the execution of 4images ?

Offline okram

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: watermark when showing pic
« Reply #34 on: September 14, 2005, 01:56:01 AM »
If anyone is Interested this is the php file I use to add text to a image on the fly

Code: [Select]
<?php
//=========== change the text to display in the image
$text 'YOURTEXT';
$imgfile$_GET['get_image'];
$font 'arial.ttf';
$ext=substr($imgfile,-3);
$ext=strtolower($ext);

if(
$ext=="jpg" || $ext=="jpe"$im=@imagecreatefromjpeg("$imgfile");
elseif (
$ext=="gif"$im=@imagecreatefromgif("$imgfile"); 
else {print 
"Unknown image format"; exit;}

 if (!
$im) { /* See if it failed */
 
      $im ImageCreate (15030); /* Create a blank image */
 
      $bgc ImageColorAllocate ($im255255255);
 
      $tc  ImageColorAllocate ($im000);
 
      ImageFilledRectangle ($im0015030$bgc); 
 
      /* Output an errmsg */
 
      ImageString($im155"Error loading $imgfile"$tc); 
return $im;
 
  }

$x=imagesx($im);
$y=imagesy($im);
$fontsize=$x/40;
$fontsize=floor($fontsize);
if(
$fontsize<10$fontsize=10;

$white imagecolorallocate($im255255255);
$black imagecolorallocate($im000);

imagettftext($im$fontsize012$fontsize+8$black$font$text);
imagettftext($im$fontsize010$fontsize+6$white$font$text);

if(
$ext=="gif"
{
header("Content-type: image/gif");
imageGIF($im);
}
else
{
header("Content-type: image/jpeg");
imagejpeg($im);

}
imagedetroy($im);
?>

I used that for sometime, but i decided not to use a text watermark but a image watermark... As far as i know the imagettftext() function requires a special library (freefonttype  :?: i do not remember the exact name) Once it didn't worked, so i started with an image watermark

Regards

Offline impss

  • Sr. Member
  • ****
  • Posts: 382
    • View Profile
    • Cusstom.net
Re: watermark when showing pic
« Reply #35 on: September 14, 2005, 01:57:17 AM »
Hum ... are these functions intended to be used as part of the execution of 4images ?

If your refering to me, I used this code in place of this mods watermark.php

Offline okram

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: watermark when showing pic
« Reply #36 on: September 14, 2005, 01:57:53 AM »
Hum ... are these functions intended to be used as part of the execution of 4images ?

which functions do you mean?

TheOracle

  • Guest
Re: watermark when showing pic
« Reply #37 on: September 14, 2005, 01:58:56 AM »
Quote

As far as i know the imagettftext() function requires a special library (freefonttype  Question i do not remember the exact name)


Correct. The name is GD Library which must be installed from the server end in order, for this MOD, to work properly. ;)

TheOracle

  • Guest
Re: watermark when showing pic
« Reply #38 on: September 14, 2005, 01:59:49 AM »
Quote

which functions do you mean?


Sorry, I meant codings - not functions. My bad. Are these codings intended to work under 4images ?

Offline impss

  • Sr. Member
  • ****
  • Posts: 382
    • View Profile
    • Cusstom.net
Re: watermark when showing pic
« Reply #39 on: September 14, 2005, 02:00:33 AM »

I used that for sometime, but i decided not to use a text watermark but a image watermark... As far as i know the imagettftext() function requires a special library (freefonttype  :?: i do not remember the exact name) Once it didn't worked, so i started with an image watermark

Regards

Yea, I was just offering this as another option

Offline okram

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: watermark when showing pic
« Reply #40 on: September 14, 2005, 02:01:34 AM »
Correct. The name is GD Library which must be installed from the server end in order, for this MOD, to work properly. ;)

No i didn't mean the gd library... that's for copying 1 image into another... for adding text to 1 image there's another library that muist be installed... let me find out more about this library and then i will make a new post here


Offline okram

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: watermark when showing pic
« Reply #41 on: September 14, 2005, 02:05:12 AM »
Sorry, I meant codings - not functions. My bad. Are these codings intended to work under 4images ?

If you're refering to this watermark codes, yeah they are intended to work along with 4images... it's just a mod for it... i guess

Regards

Offline okram

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: watermark when showing pic
« Reply #42 on: September 14, 2005, 02:12:24 AM »
let me find out more about this library and then i will make a new post here

This function requires both the GD library and the FreeType library....

yeah that's it... the name is freetype library...

Please read this article -> http://cheetahscripts.com/modules.php?name=PHP_Manual&page=function.imagettftext.html <- That's what i meant

Regards

TheOracle

  • Guest
Re: watermark when showing pic
« Reply #43 on: September 14, 2005, 02:14:44 AM »
Thanks for mentionning about the freetype module.

As for :

Quote

it's just a mod for it... i guess


Well ... actually, I don't mean to be rude but, even if the idea is great, it is a highly unsecured one as no sessions protection has been preset in that MOD.  8O

Offline okram

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: watermark when showing pic
« Reply #44 on: September 14, 2005, 02:26:07 AM »
Well ... actually, I don't mean to be rude but, even if the idea is great, it is a highly unsecured one as no sessions protection has been preset in that MOD.  8O

I think there's no a strong reason to prevent the direct access to this file. At least in my case, it's not in my plans setting a complete high secure system for this page... all we want is prevent the direct access from standard users... i mean we don't expect all visitors know php programming or stuff like that.. as i said... all we want is prevent the directaccess to standard users, and those users represent the 95 % or more of our visitors... so i think no secure systems are required for this last mod, the one that sets a session variable...

Regards