Re: [PHP] Watermark with GD

2010-10-31 Thread Tamara Temple


On Oct 31, 2010, at 7:29 AM, Gary wrote:

Thanks for the reply, here is a link to the code of the page.

http://www.paulgdesigns.com/detailcode.php



Ok, that was pretty messy code. But what I could glean from it is  
this. (See your code at http://pastie.org/1262989).


Line 238: width="auto">class="WADADetailsMainImage" style="border:#FF 6px solid"  
src="images/" alt="echo $row_WADAimages["description"]; ?>" />width="25%"> This photo was taken in $row_WADAimages["where_taken"]; ?>


You've got an img tag there, indicating the src of:

images/

Is this the image file you want to watermark?

The code there has me confused. Is this all one script? Or is it  
multiple scripts?


If it's all one script, it won't work the way you intend. The script  
emits data before it gets to the point where you have set up to  
watermark the image. Thus, the point where you call header to change  
the Content-type won't work. Then there is more data emitted after the  
image.


Am I reading this correctly? Is it all one big script?

If it is, what you really need to do, is at the point where you want  
the watermarked image to appear, is put out some HTML like so:


" .. other stuff ..>


Then put that code you've got in lines 247-272 in the script  
watermark.php and it should work as is.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Watermark with GD

2010-10-31 Thread tedd

At 12:12 PM -0400 10/31/10, Gary wrote:

"tedd"  wrote in message
news:p06240800c8f339e20...@[192.168.1.2]...

 At 9:19 AM -0400 10/31/10, Gary wrote:

I was sure that the images were being stored and called from the images
folder and not directly from the DB, that is until tedd brought it up.  I
did have an issue of getting the images to show in the beginning, however
I
solved it by inserting the path in the call from the DB.  I am wondering
now
if they are stored in both locations.

Gary


 Gary:

 Both locations? I think you are confusing yourself.You either have the
 images stored in the database OR the file system, but not both.

 However, I think you have the images stored as files within the file
 directory, such as:

 http://yourdomain.com/images/picture1.jpg

 Now, in your database you should have only the path name stored (i.e.,
 images/picture1.jpg) and not the image. However, I usually only store the
 file names and NOT the path. That way I can move the images to where ever
 I want and only change their reference in the HTML.

 To recap, to show any image you use the HTML img tag, such as:

 

 To tie this statement to a database, you need to pull out the image name
 (or file path) from the database and use that. Something like this:

 $query = "SELECT file_name FROM pictures WHERE id = '$id' ";
 $result = mysql_query($query) or die();
 $row = mysql_fetch_array($result);
 $file_name = $row['file_name'];

 And then in the HTML you would use:

 

 If you can get to this part, then we can deal with placing a watermark on
 the image before showing it.

 Please let me know when you get this part to work.

 Cheers,

 tedd

 PS: There is no need to use a LONG BLOB in your database -- that's just a
 waste of space.

 --
 ---
 http://sperling.com/



tedd

Thank you for your reply.

I have the images being displayed in the browser fine, my issue was that I
was not able to get the watermark to show up.  I believe the issue was here

$img=imagecreatefromjpeg($_GET['pic']);

in that 'pic' is asking for the image that I wanted the watermark displayed
on, and what I put in did not work.  Since the image file name is being
stored in the DB, I tried

$row_WADAimages["image_file"]

as well as a few others.

What do you suggest I changed "longblob" to, and is it safe to do so?

Again, thank you for your help.

gary


gary:

At some point you're going to have to learn:

1. The difference between a VARCHR and a LONGBLOB. Question: If you 
are simply storing the name of an image file, then why use a LONGBLOB 
to do that? Please look up the difference between the two and post 
your findings here;


2. The GET (again) is *not* the way to get the name of the image. I 
have shown you how to pull the name of the image via a database call 
-- so why do you go back to your old code telling me what the problem 
is? If you already know what the problem is, then why ask me?


3. If you want my help, then use what I have shown you instead of 
going back to your past problematic solution.


It looks to me as if you are not willing to learn but rather are 
looking for a simple solution. I am not going to write your code for 
you.


Now, please use my last email and write code to present an image as I 
demonstrated to you. When you can do that, then we can address how to 
put a watermark on the image. However, if you fail to do that and 
continue to bring up old nonsensical code, then I will discontinue 
commenting re this thread.


Cheers,

tedd

--
---
http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Watermark with GD

2010-10-31 Thread Gary

"tedd"  wrote in message 
news:p06240800c8f339e20...@[192.168.1.2]...
> At 9:19 AM -0400 10/31/10, Gary wrote:
>>I was sure that the images were being stored and called from the images
>>folder and not directly from the DB, that is until tedd brought it up.  I
>>did have an issue of getting the images to show in the beginning, however 
>>I
>>solved it by inserting the path in the call from the DB.  I am wondering 
>>now
>>if they are stored in both locations.
>>
>>Gary
>
> Gary:
>
> Both locations? I think you are confusing yourself.You either have the 
> images stored in the database OR the file system, but not both.
>
> However, I think you have the images stored as files within the file 
> directory, such as:
>
> http://yourdomain.com/images/picture1.jpg
>
> Now, in your database you should have only the path name stored (i.e., 
> images/picture1.jpg) and not the image. However, I usually only store the 
> file names and NOT the path. That way I can move the images to where ever 
> I want and only change their reference in the HTML.
>
> To recap, to show any image you use the HTML img tag, such as:
>
> 
>
> To tie this statement to a database, you need to pull out the image name 
> (or file path) from the database and use that. Something like this:
>
> $query = "SELECT file_name FROM pictures WHERE id = '$id' ";
> $result = mysql_query($query) or die();
> $row = mysql_fetch_array($result);
> $file_name = $row['file_name'];
>
> And then in the HTML you would use:
>
> 
>
> If you can get to this part, then we can deal with placing a watermark on 
> the image before showing it.
>
> Please let me know when you get this part to work.
>
> Cheers,
>
> tedd
>
> PS: There is no need to use a LONG BLOB in your database -- that's just a 
> waste of space.
>
> -- 
> ---
> http://sperling.com/


tedd

Thank you for your reply.

I have the images being displayed in the browser fine, my issue was that I 
was not able to get the watermark to show up.  I believe the issue was here

$img=imagecreatefromjpeg($_GET['pic']);

in that 'pic' is asking for the image that I wanted the watermark displayed 
on, and what I put in did not work.  Since the image file name is being 
stored in the DB, I tried

$row_WADAimages["image_file"]

as well as a few others.

What do you suggest I changed "longblob" to, and is it safe to do so?

Again, thank you for your help.

gary 



__ Information from ESET Smart Security, version of virus signature 
database 5579 (20101031) __

The message was checked by ESET Smart Security.

http://www.eset.com





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Watermark with GD

2010-10-31 Thread tedd

At 9:19 AM -0400 10/31/10, Gary wrote:

I was sure that the images were being stored and called from the images
folder and not directly from the DB, that is until tedd brought it up.  I
did have an issue of getting the images to show in the beginning, however I
solved it by inserting the path in the call from the DB.  I am wondering now
if they are stored in both locations.

Gary


Gary:

Both locations? I think you are confusing yourself.You either have 
the images stored in the database OR the file system, but not both.


However, I think you have the images stored as files within the file 
directory, such as:


http://yourdomain.com/images/picture1.jpg

Now, in your database you should have only the path name stored 
(i.e., images/picture1.jpg) and not the image. However, I usually 
only store the file names and NOT the path. That way I can move the 
images to where ever I want and only change their reference in the 
HTML.


To recap, to show any image you use the HTML img tag, such as:



To tie this statement to a database, you need to pull out the image 
name (or file path) from the database and use that. Something like 
this:


$query = "SELECT file_name FROM pictures WHERE id = '$id' ";
$result = mysql_query($query) or die();
$row = mysql_fetch_array($result);
$file_name = $row['file_name'];

And then in the HTML you would use:



If you can get to this part, then we can deal with placing a 
watermark on the image before showing it.


Please let me know when you get this part to work.

Cheers,

tedd

PS: There is no need to use a LONG BLOB in your database -- that's 
just a waste of space.


--
---
http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Watermark with GD

2010-10-31 Thread Gary
Tamara

I realized I forgot to answer your question about file_name.  It is a text 
field that the photographer enters the name of the image file for easy 
reference.  He does not have access to the DB and he is inserting the images 
from a form I created.

I was sure that the images were being stored and called from the images 
folder and not directly from the DB, that is until tedd brought it up.  I 
did have an issue of getting the images to show in the beginning, however I 
solved it by inserting the path in the call from the DB.  I am wondering now 
if they are stored in both locations.

Thank again

Gary

"Tamara Temple"  wrote in message 
news:94df613c-6b40-4897-b101-21cf7d83a...@gmail.com...
>
> On Oct 30, 2010, at 9:31 AM, Gary wrote:
>
>>
>> "tedd"  wrote in message
>> news:p06240800c8f1d19b9...@[192.168.1.2]...
>>> At 3:05 PM -0400 10/29/10, Gary wrote:
 I am trying to get the watermark to work, however I am having a 
 problem in
 that the image is being called from a database (image sits in images
 file).

 The script in question is this

 $image = imagecreatefromjpeg($_GET['src']);

 However it produces an error message of

 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 
 Filename
 cannot be empty in /home/content/a/l/i/alinde52/html/ imagesDetail.php 
 on
 line 233

 I have tried various methods, for example: ($_GET ['images/'] or 
 ($_GET
 ['images/$row_WADAimages["image_id"]].

 Can anyone shed some light on this for me.

 Thank you

 Gary
>>>
>>> Gary:
>>>
>>> Several things.
>>>
>>> 1. Getting an image from a database? You mean that you are getting  the
>>> path of the image in the file system, right?
>>>
>>> Side note: You could place the image inside the database using a  BLOB 
>>> and
>>> do away with the path all together. That has the benefit of being
>>> portable -- you simply move the database to where ever you want it.  The
>>> downside is that the database becomes very large, but no more so  that 
>>> the
>>> file system. There are pro's and con's in storing actual images in a
>>> database.
>>>
>>> 2. Using a GET is not the way to get the path. Instead, you have to
>>> retrieve the path from the database table where the path is stored --
>>> and that requires a MySQL query similar to "SELECT * FROM   
>>> WHERE
>>> id=". There are lot's of examples of how to pull data  from a
>>> database.
>>>
>>> 3. After getting the path, then you can create the watermark like so:
>>>
>>> http://webbytedd.com/b/watermark/
>>>
>>> Hope this helps,
>>>
>>> tedd
>>>
>>> -- 
>>> ---
>>> http://sperling.com/
>>>
>>
>> tedd
>>
>> Thank you for your reply.
>>
>> I was under the impression that the image is stored in a folder called
>> images, in fact the images file do go in, however I have the DB set  up 
>> for
>> longblob, averaging about 20kb each, so now I am unsure.  I exported  the 
>> sql
>> so perhaps you can tell me.
>>
>> Table structure for table `images`
>> --
>>
>> CREATE TABLE IF NOT EXISTS `images` (
>>  `image_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
>>  `caption` varchar(50) NOT NULL,
>>  `wheretaken` varchar(100) NOT NULL,
>>  `description` text NOT NULL,
>>  `file_name` varchar(25) NOT NULL,
>>  `image_file` longblob NOT NULL,
>>  `submitted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
>>  PRIMARY KEY (`image_id`)
>> ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1447 ;
>>
>> When I call the images, which works fine, I do need to specify the  path 
>> that
>> leads to the images folder. Am I being redundant in this structure.
>>
>> This is the script that I use to call the images. I have pulled out  some 
>> of
>> the html that styles the data.
>>
>>  0) { // Show if recordset not  empty ?>
>>  
>>  src="images/" > $row_WADAimages["description"]; ?>"
>>
>> 
>>
>>
>> Thank you for your help.
>>
>> Gary
>
> is this the imageDetail.php script?
>
> From what it appears in the code, `image_file` is holding the file  name 
> rather than the actual image. Yet you have `image_file` defined  as a 
> longblob, which would make sense if you were storing the actual  image 
> data in the data base rather than on the file system. As Ashley  noted, 
> you can do it either way. I notice you also have a field  `file_name` --  
> what is this used for? It sounds like your design is a  bit off -- neither 
> one way or the other. The php shown doesn't look  complete enough, 
> though -- where is the img tag and such? Also, going  in and out of php on 
> each line is kind of a waste and looks sloppy. If  i read that code right, 
> it would emit something like this:
>
>
> caption text
> src="images/pathtoimagefile" description text
>
> where taken text
> description text
>
> Look at the html that's emitted from the script and see if that's what 
> you get.
>
> Can you post or pastebin more of the .php script so I can see more of 
> what is going on?

Re: [PHP] Watermark with GD

2010-10-31 Thread Gary

"Tamara Temple"  wrote in message 
news:94df613c-6b40-4897-b101-21cf7d83a...@gmail.com...
>
> On Oct 30, 2010, at 9:31 AM, Gary wrote:
>
>>
>> "tedd"  wrote in message
>> news:p06240800c8f1d19b9...@[192.168.1.2]...
>>> At 3:05 PM -0400 10/29/10, Gary wrote:
 I am trying to get the watermark to work, however I am having a 
 problem in
 that the image is being called from a database (image sits in images
 file).

 The script in question is this

 $image = imagecreatefromjpeg($_GET['src']);

 However it produces an error message of

 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 
 Filename
 cannot be empty in /home/content/a/l/i/alinde52/html/ imagesDetail.php 
 on
 line 233

 I have tried various methods, for example: ($_GET ['images/'] or 
 ($_GET
 ['images/$row_WADAimages["image_id"]].

 Can anyone shed some light on this for me.

 Thank you

 Gary
>>>
>>> Gary:
>>>
>>> Several things.
>>>
>>> 1. Getting an image from a database? You mean that you are getting  the
>>> path of the image in the file system, right?
>>>
>>> Side note: You could place the image inside the database using a  BLOB 
>>> and
>>> do away with the path all together. That has the benefit of being
>>> portable -- you simply move the database to where ever you want it.  The
>>> downside is that the database becomes very large, but no more so  that 
>>> the
>>> file system. There are pro's and con's in storing actual images in a
>>> database.
>>>
>>> 2. Using a GET is not the way to get the path. Instead, you have to
>>> retrieve the path from the database table where the path is stored --
>>> and that requires a MySQL query similar to "SELECT * FROM   
>>> WHERE
>>> id=". There are lot's of examples of how to pull data  from a
>>> database.
>>>
>>> 3. After getting the path, then you can create the watermark like so:
>>>
>>> http://webbytedd.com/b/watermark/
>>>
>>> Hope this helps,
>>>
>>> tedd
>>>
>>> -- 
>>> ---
>>> http://sperling.com/
>>>
>>
>> tedd
>>
>> Thank you for your reply.
>>
>> I was under the impression that the image is stored in a folder called
>> images, in fact the images file do go in, however I have the DB set  up 
>> for
>> longblob, averaging about 20kb each, so now I am unsure.  I exported  the 
>> sql
>> so perhaps you can tell me.
>>
>> Table structure for table `images`
>> --
>>
>> CREATE TABLE IF NOT EXISTS `images` (
>>  `image_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
>>  `caption` varchar(50) NOT NULL,
>>  `wheretaken` varchar(100) NOT NULL,
>>  `description` text NOT NULL,
>>  `file_name` varchar(25) NOT NULL,
>>  `image_file` longblob NOT NULL,
>>  `submitted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
>>  PRIMARY KEY (`image_id`)
>> ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1447 ;
>>
>> When I call the images, which works fine, I do need to specify the  path 
>> that
>> leads to the images folder. Am I being redundant in this structure.
>>
>> This is the script that I use to call the images. I have pulled out  some 
>> of
>> the html that styles the data.
>>
>>  0) { // Show if recordset not  empty ?>
>>  
>>  src="images/" > $row_WADAimages["description"]; ?>"
>>
>> 
>>
>>
>> Thank you for your help.
>>
>> Gary
>
> is this the imageDetail.php script?
>
> From what it appears in the code, `image_file` is holding the file  name 
> rather than the actual image. Yet you have `image_file` defined  as a 
> longblob, which would make sense if you were storing the actual  image 
> data in the data base rather than on the file system. As Ashley  noted, 
> you can do it either way. I notice you also have a field  `file_name` --  
> what is this used for? It sounds like your design is a  bit off -- neither 
> one way or the other. The php shown doesn't look  complete enough, 
> though -- where is the img tag and such? Also, going  in and out of php on 
> each line is kind of a waste and looks sloppy. If  i read that code right, 
> it would emit something like this:
>
>
> caption text
> src="images/pathtoimagefile" description text
>
> where taken text
> description text
>
> Look at the html that's emitted from the script and see if that's what 
> you get.
>
> Can you post or pastebin more of the .php script so I can see more of 
> what is going on?
>

Tamara

Thanks for the reply, here is a link to the code of the page.

http://www.paulgdesigns.com/detailcode.php

Again, thank you for your help.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5578 (20101031) __

The message was checked by ESET Smart Security.

http://www.eset.com





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Watermark with GD

2010-10-30 Thread Tamara Temple


On Oct 30, 2010, at 9:31 AM, Gary wrote:



"tedd"  wrote in message
news:p06240800c8f1d19b9...@[192.168.1.2]...

At 3:05 PM -0400 10/29/10, Gary wrote:
I am trying to get the watermark to work, however I am having a  
problem in

that the image is being called from a database (image sits in images
file).

The script in question is this

$image = imagecreatefromjpeg($_GET['src']);

However it produces an error message of

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]:  
Filename
cannot be empty in /home/content/a/l/i/alinde52/html/ 
imagesDetail.php on

line 233

I have tried various methods, for example: ($_GET ['images/'] or  
($_GET

['images/$row_WADAimages["image_id"]].

Can anyone shed some light on this for me.

Thank you

Gary


Gary:

Several things.

1. Getting an image from a database? You mean that you are getting  
the

path of the image in the file system, right?

Side note: You could place the image inside the database using a  
BLOB and

do away with the path all together. That has the benefit of being
portable -- you simply move the database to where ever you want it.  
The
downside is that the database becomes very large, but no more so  
that the

file system. There are pro's and con's in storing actual images in a
database.

2. Using a GET is not the way to get the path. Instead, you have to
retrieve the path from the database table where the path is stored --
and that requires a MySQL query similar to "SELECT * FROM  
 WHERE
id=". There are lot's of examples of how to pull data  
from a

database.

3. After getting the path, then you can create the watermark like so:

http://webbytedd.com/b/watermark/

Hope this helps,

tedd

--
---
http://sperling.com/



tedd

Thank you for your reply.

I was under the impression that the image is stored in a folder called
images, in fact the images file do go in, however I have the DB set  
up for
longblob, averaging about 20kb each, so now I am unsure.  I exported  
the sql

so perhaps you can tell me.

Table structure for table `images`
--

CREATE TABLE IF NOT EXISTS `images` (
 `image_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `caption` varchar(50) NOT NULL,
 `wheretaken` varchar(100) NOT NULL,
 `description` text NOT NULL,
 `file_name` varchar(25) NOT NULL,
 `image_file` longblob NOT NULL,
 `submitted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
 PRIMARY KEY (`image_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1447 ;

When I call the images, which works fine, I do need to specify the  
path that

leads to the images folder. Am I being redundant in this structure.

This is the script that I use to call the images. I have pulled out  
some of

the html that styles the data.

 0) { // Show if recordset not  
empty ?>

 
 src="images/" "


   

Thank you for your help.

Gary


is this the imageDetail.php script?

From what it appears in the code, `image_file` is holding the file  
name rather than the actual image. Yet you have `image_file` defined  
as a longblob, which would make sense if you were storing the actual  
image data in the data base rather than on the file system. As Ashley  
noted, you can do it either way. I notice you also have a field  
`file_name` -- what is this used for? It sounds like your design is a  
bit off -- neither one way or the other. The php shown doesn't look  
complete enough, though -- where is the img tag and such? Also, going  
in and out of php on each line is kind of a waste and looks sloppy. If  
i read that code right, it would emit something like this:



caption text
src="images/pathtoimagefile" description text

where taken text
description text

Look at the html that's emitted from the script and see if that's what  
you get.


Can you post or pastebin more of the .php script so I can see more of  
what is going on?




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Watermark with GD

2010-10-30 Thread Ashley Sheridan
On Sat, 2010-10-30 at 11:50 -0400, Gary wrote:

> "tedd"  wrote in message 
> news:p06240804c8f1eaf38...@[192.168.1.2]...
> > At 10:31 AM -0400 10/30/10, Gary wrote:
> >>
> >>I was under the impression that the image is stored in a folder called
> >>images, in fact the images file do go in, however I have the DB set up for
> >>longblob, averaging about 20kb each, so now I am unsure.  I exported the 
> >>sql
> >>so perhaps you can tell me.
> >
> > Gary:
> >
> > Impressions don't cut it -- you should *know* if the actual images are in 
> > the file system or in the database. Find that out before we can proceed.
> >
> > Cheers,
> >
> > tedd
> >
> >
> > -- 
> > ---
> > http://sperling.com/
> 
> tedd
> 
> The images do go into the images folder, what I am now unclear about is 
> where they are being called from.
> 
> Gary 
> 
> 
> 
> __ Information from ESET Smart Security, version of virus signature 
> database 5576 (20101029) __
> 
> The message was checked by ESET Smart Security.
> 
> http://www.eset.com
> 
> 
> 
> 
> 


OK, what it looks like is that the path to your image file is being
stored in the database, and you're outputting that path inside of an
 tag when you output the HTML. That's fine, and is the method I use
all the time.

Now, back to the original question. You want to overlay some text on it
as a watermark? For that, you need to use the GD functions.

First, use GD to load in the image. Note that the path you use to open
the image here won't be the same as the one you have in the DB. That's
because the one in the DB is the path that is available to web browsers
to reference your image, which is uses relative to your web page. For
example, if your page was at
http://www.someplace.com/somefolder/page/php, and the image tag looked
like  the browser path to the images would
be http://www.someplace.com/somefolder/image.jpg , but the script path
to your image would be very different, such as one of the following:


  * c:\xampp\htdocs\websitename\somefolder\images\image.jpg (xampp
on windows)
  * /var/www/html/websitename/somefolder/images/image.jpg (linux)
  * /srv/www/websitename/somefolder/images/image.jpg (linux)
  * /home/websitename/somefolder/images/image.jpg (linux)


Those are only examples, and may not necessarily be the exact setup you
have on your server, you should find out exactly what the server is
running. You can also reference it via a relative path, which is
relative to the PHP script.

With GD, you can either save a duplicate of the image with the watermark
on, with a useful name such as watermark_image.jpg, or you can output it
directly with the proper headers. If you do choose the latter route, you
should ideally make a separate image script for making the watermark
image, and in your image tag, call it with something like:



The id can be whatever id you've got for the image in your database, and
then in your image.php script, make the DB call that grabs the
information for that image, and create the watermark. Just remember to
make sure you send the right headers or your image won't show!

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Watermark with GD

2010-10-30 Thread Gary

"tedd"  wrote in message 
news:p06240804c8f1eaf38...@[192.168.1.2]...
> At 10:31 AM -0400 10/30/10, Gary wrote:
>>
>>I was under the impression that the image is stored in a folder called
>>images, in fact the images file do go in, however I have the DB set up for
>>longblob, averaging about 20kb each, so now I am unsure.  I exported the 
>>sql
>>so perhaps you can tell me.
>
> Gary:
>
> Impressions don't cut it -- you should *know* if the actual images are in 
> the file system or in the database. Find that out before we can proceed.
>
> Cheers,
>
> tedd
>
>
> -- 
> ---
> http://sperling.com/

tedd

The images do go into the images folder, what I am now unclear about is 
where they are being called from.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5576 (20101029) __

The message was checked by ESET Smart Security.

http://www.eset.com





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Watermark with GD

2010-10-30 Thread tedd

At 10:31 AM -0400 10/30/10, Gary wrote:


I was under the impression that the image is stored in a folder called
images, in fact the images file do go in, however I have the DB set up for
longblob, averaging about 20kb each, so now I am unsure.  I exported the sql
so perhaps you can tell me.


Gary:

Impressions don't cut it -- you should *know* if the actual images 
are in the file system or in the database. Find that out before we 
can proceed.


Cheers,

tedd


--
---
http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Watermark with GD

2010-10-30 Thread Gary

"Tamara Temple"  wrote in message 
news:7f666311-4bc8-4064-8c70-4f2597e7b...@gmail.com...
> On Oct 29, 2010, at 2:44 PM, Gary wrote:
>> "Adam Richardson"  wrote in message
>> news:aanlkti=kenxt7yewrztcm4+hyifrlqhozxse7ufmq...@mail.gmail.com...
>> On Fri, Oct 29, 2010 at 3:05 PM, Gary  wrote:
>>> I am trying to get the watermark to work, however I am having a  problem 
>>> in
>>> that the image is being called from a database (image sits in images
>>> file).
>>>
>>> The script in question is this
>>>
>>> $image = imagecreatefromjpeg($_GET['src']);
>>>
>>> However it produces an error message of
>>>
>>> Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]:  Filename
>>> cannot be empty in /home/content/a/l/i/alinde52/html/ imagesDetail.php 
>>> on
>>> line 233
>>>
>>
>> First things first.  It looks like there's nothing in $_GET['src'].
>> From where are you getting the value 'src'?
>>
>> Adam
>>
>> **
>> Adam
>>
>> Thanks for your reply, that is my question, what is to replace  ['src'] 
>> if I
>> am calling the image from a database.
>>
>> Gary
>
> I'd really need to know more about this application to help. If you  are 
> calling the image from a database (does this mean you have the  image's 
> file spec saved in the database, or you actually storing the  image data 
> in the database?), you need to use a query to do that. Is  the 
> imagesDetail.php script being called by something else that  already 
> queried the database and put the file spec in the src query  string 
> argument? Before you dump the query string argument directly  into the 
> imagecreatefromjpeg() funciton, you should verify that it  exists:
>
> if (isset($_GET['src'[) && (!empty($_GET['src'[) {
> $src = $_GET['src'];
> if (fileexists($src)) {
>  $image = imageceatefromjpeg($src);
> if ($image === FALSE) {
> # process error from imagecreatefromjpeg
> }
> } else {
>  # process missing image
> }
> } else {
>  # process missing query string parameter
> }
>
> This is all prediated on the idea that something is calling your 
> imageDetail.php script with the source path for the image in question.  If 
> that is not the case, and you need to in fact query the database  for the 
> source path of the image, then you need to do a database query.
>
> Not knowing anything about how your database is set up, I'll take a  stab 
> at a generic method of doing it.
>
> Somehow, imageDetail.php needs to know what image to get. Let's assume 
> you are calling it from a gallery that has several images displayed.  Part 
> of the information needed is some what to identify the image's  record in 
> the database. Let's assume you have images stored with an  id, that is not 
> null and autoincrements when you store a new image.  Here's a sample 
> schema:
>
> CREATE TABLE `photos` (
> `id` INT AUTO_INCREMENT NOT NULL,
> `src` VARCHAR(255) NOT NULL,
> `created` TIMESTAMP NOT NULL DEFAULT 0,
> `updated` TIMESTAMP NOT NULL DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP
> PRIMARY KEY (`id`)
> );
>
> Of course, you would probably want to store a lot more info about an 
> image, but this will do for explanation.
>
> Let's say you have a gallery shown at your application's index.php 
> program. In the html it generates, you may have something like this  for 
> any particular thumbnail:
>
>
> 
>
> This is making some assumptions:
>   * you have image thumbnails for each image stored in the  subdirectory 
> thumbs/
>   * you've figured out somehow that the id for thumbs/imageABC.jpg is  25
>
> When the user clicks on the image, they get taken to your  imageDetail.php 
> script, with the query string paramter id set to 25.
>
> In PHP you would then do:
>
> if (isset($_GET['id'] && (!empty($_GET['id'] &&  is_numeric($_GET['id']) {
> $id = $_GET['id'];
> $sql = "SELECT * FROM `photos` WHERE id=".$id." LIMIT 1";
> $result = mysql_query($sql,$db);
> if ($result) {
> $imagedata = mysql_fetch_array($result,MYSQL_ASSOC);
> $src = $imagedata['src'];
> if (isset($src) && !empty($src) && fileexists($src)) {
> $image = imagecreatefromjpeg($src);
>
> # do stuff with image
>
> } else {
>
> # handle invalid src data
>
> }
> } else {
>
> # handle error from query
>
> }
> } else {
>
> # handle invalid id paramter on script
>
> }
>
>
> Note: some people like to handle error conditions before moving on to 
> working with the successful state. It's a matter of style. Either works.
>
> Hope this helps.
>
> Tamara
>
Tamara

Thanks for your reply.  The image is already called, (and if you read the 
response I posted to tedd, you'll see I am now not sure how it is). I also 
posted the code that calls the image if that sheds any light.

I am digesting all the information to get it to work, if any of the code 
changes your answer, I would love to hear it!

Thank you again.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5576 (20101029) __

The message was checked by ESET Smart Security.

http

Re: [PHP] Watermark with GD

2010-10-30 Thread Gary

"tedd"  wrote in message 
news:p06240800c8f1d19b9...@[192.168.1.2]...
> At 3:05 PM -0400 10/29/10, Gary wrote:
>>I am trying to get the watermark to work, however I am having a problem in
>>that the image is being called from a database (image sits in images 
>>file).
>>
>>The script in question is this
>>
>>$image = imagecreatefromjpeg($_GET['src']);
>>
>>However it produces an error message of
>>
>>Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: Filename
>>cannot be empty in /home/content/a/l/i/alinde52/html/imagesDetail.php on
>>line 233
>>
>>I have tried various methods, for example: ($_GET ['images/'] or ($_GET
>>['images/$row_WADAimages["image_id"]].
>>
>>Can anyone shed some light on this for me.
>>
>>Thank you
>>
>>Gary
>
> Gary:
>
> Several things.
>
> 1. Getting an image from a database? You mean that you are getting the 
> path of the image in the file system, right?
>
> Side note: You could place the image inside the database using a BLOB and 
> do away with the path all together. That has the benefit of being 
> portable -- you simply move the database to where ever you want it. The 
> downside is that the database becomes very large, but no more so that the 
> file system. There are pro's and con's in storing actual images in a 
> database.
>
> 2. Using a GET is not the way to get the path. Instead, you have to 
> retrieve the path from the database table where the path is stored -- 
> and that requires a MySQL query similar to "SELECT * FROM  WHERE 
> id=". There are lot's of examples of how to pull data from a 
> database.
>
> 3. After getting the path, then you can create the watermark like so:
>
> http://webbytedd.com/b/watermark/
>
> Hope this helps,
>
> tedd
>
> -- 
> ---
> http://sperling.com/
>

tedd

Thank you for your reply.

I was under the impression that the image is stored in a folder called 
images, in fact the images file do go in, however I have the DB set up for 
longblob, averaging about 20kb each, so now I am unsure.  I exported the sql 
so perhaps you can tell me.

Table structure for table `images`
--

CREATE TABLE IF NOT EXISTS `images` (
  `image_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `caption` varchar(50) NOT NULL,
  `wheretaken` varchar(100) NOT NULL,
  `description` text NOT NULL,
  `file_name` varchar(25) NOT NULL,
  `image_file` longblob NOT NULL,
  `submitted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`image_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1447 ;

When I call the images, which works fine, I do need to specify the path that 
leads to the images folder. Am I being redundant in this structure.

This is the script that I use to call the images. I have pulled out some of 
the html that styles the data.

 0) { // Show if recordset not empty ?>
  
  src="images/" "

 


Thank you for your help.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5576 (20101029) __

The message was checked by ESET Smart Security.

http://www.eset.com





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Watermark with GD

2010-10-30 Thread tedd

At 3:05 PM -0400 10/29/10, Gary wrote:

I am trying to get the watermark to work, however I am having a problem in
that the image is being called from a database (image sits in images file).

The script in question is this

$image = imagecreatefromjpeg($_GET['src']);

However it produces an error message of

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: Filename
cannot be empty in /home/content/a/l/i/alinde52/html/imagesDetail.php on
line 233

I have tried various methods, for example: ($_GET ['images/'] or ($_GET
['images/$row_WADAimages["image_id"]].

Can anyone shed some light on this for me.

Thank you

Gary


Gary:

Several things.

1. Getting an image from a database? You mean that you are getting 
the path of the image in the file system, right?


Side note: You could place the image inside the database using a BLOB 
and do away with the path all together. That has the benefit of being 
portable -- you simply move the database to where ever you want it. 
The downside is that the database becomes very large, but no more so 
that the file system. There are pro's and con's in storing actual 
images in a database.


2. Using a GET is not the way to get the path. Instead, you have to 
retrieve the path from the database table where the path is stored -- 
and that requires a MySQL query similar to "SELECT * FROM  
WHERE id=". There are lot's of examples of how to pull data 
from a database.


3. After getting the path, then you can create the watermark like so:

http://webbytedd.com/b/watermark/

Hope this helps,

tedd

--
---
http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Watermark with GD

2010-10-29 Thread Tamara Temple

On Oct 29, 2010, at 2:44 PM, Gary wrote:

"Adam Richardson"  wrote in message
news:aanlkti=kenxt7yewrztcm4+hyifrlqhozxse7ufmq...@mail.gmail.com...
On Fri, Oct 29, 2010 at 3:05 PM, Gary  wrote:
I am trying to get the watermark to work, however I am having a  
problem in

that the image is being called from a database (image sits in images
file).

The script in question is this

$image = imagecreatefromjpeg($_GET['src']);

However it produces an error message of

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]:  
Filename
cannot be empty in /home/content/a/l/i/alinde52/html/ 
imagesDetail.php on

line 233



First things first.  It looks like there's nothing in $_GET['src'].
From where are you getting the value 'src'?

Adam

**
Adam

Thanks for your reply, that is my question, what is to replace  
['src'] if I

am calling the image from a database.

Gary


I'd really need to know more about this application to help. If you  
are calling the image from a database (does this mean you have the  
image's file spec saved in the database, or you actually storing the  
image data in the database?), you need to use a query to do that. Is  
the imagesDetail.php script being called by something else that  
already queried the database and put the file spec in the src query  
string argument? Before you dump the query string argument directly  
into the imagecreatefromjpeg() funciton, you should verify that it  
exists:


if (isset($_GET['src'[) && (!empty($_GET['src'[) {
$src = $_GET['src'];
if (fileexists($src)) {
 $image = imageceatefromjpeg($src);
if ($image === FALSE) {
# process error from imagecreatefromjpeg
}
} else {
 # process missing image
}
} else {
 # process missing query string parameter
}

This is all prediated on the idea that something is calling your  
imageDetail.php script with the source path for the image in question.  
If that is not the case, and you need to in fact query the database  
for the source path of the image, then you need to do a database query.


Not knowing anything about how your database is set up, I'll take a  
stab at a generic method of doing it.


Somehow, imageDetail.php needs to know what image to get. Let's assume  
you are calling it from a gallery that has several images displayed.  
Part of the information needed is some what to identify the image's  
record in the database. Let's assume you have images stored with an  
id, that is not null and autoincrements when you store a new image.  
Here's a sample schema:


CREATE TABLE `photos` (
`id`INT AUTO_INCREMENT NOT NULL,
`src`   VARCHAR(255) NOT NULL,
`created`   TIMESTAMP NOT NULL DEFAULT 0,
`updated`   TIMESTAMP NOT NULL DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP
PRIMARY KEY (`id`)
);

Of course, you would probably want to store a lot more info about an  
image, but this will do for explanation.


Let's say you have a gallery shown at your application's index.php  
program. In the html it generates, you may have something like this  
for any particular thumbnail:





This is making some assumptions:
  * you have image thumbnails for each image stored in the  
subdirectory thumbs/
  * you've figured out somehow that the id for thumbs/imageABC.jpg is  
25


When the user clicks on the image, they get taken to your  
imageDetail.php script, with the query string paramter id set to 25.


In PHP you would then do:

if (isset($_GET['id'] && (!empty($_GET['id'] &&  
is_numeric($_GET['id']) {

$id = $_GET['id'];
$sql = "SELECT * FROM `photos` WHERE id=".$id." LIMIT 1";
$result = mysql_query($sql,$db);
if ($result) {
$imagedata = mysql_fetch_array($result,MYSQL_ASSOC);
$src = $imagedata['src'];
if (isset($src) && !empty($src) && fileexists($src)) {
$image = imagecreatefromjpeg($src);

# do stuff with image

} else {

# handle invalid src data

}
} else {

# handle error from query

}
} else {

# handle invalid id paramter on script

}


Note: some people like to handle error conditions before moving on to  
working with the successful state. It's a matter of style. Either works.


Hope this helps.

Tamara
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Watermark with GD

2010-10-29 Thread Gary

"Adam Richardson"  wrote in message 
news:aanlkti=kenxt7yewrztcm4+hyifrlqhozxse7ufmq...@mail.gmail.com...
On Fri, Oct 29, 2010 at 3:05 PM, Gary  wrote:
> I am trying to get the watermark to work, however I am having a problem in
> that the image is being called from a database (image sits in images 
> file).
>
> The script in question is this
>
> $image = imagecreatefromjpeg($_GET['src']);
>
> However it produces an error message of
>
> Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: Filename
> cannot be empty in /home/content/a/l/i/alinde52/html/imagesDetail.php on
> line 233
>

First things first.  It looks like there's nothing in $_GET['src'].
>From where are you getting the value 'src'?

Adam

**
Adam

Thanks for your reply, that is my question, what is to replace ['src'] if I 
am calling the image from a database.

Gary



__ Information from ESET Smart Security, version of virus signature 
database 5575 (20101029) __

The message was checked by ESET Smart Security.

http://www.eset.com





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Watermark with GD

2010-10-29 Thread Adam Richardson
On Fri, Oct 29, 2010 at 3:05 PM, Gary  wrote:
> I am trying to get the watermark to work, however I am having a problem in
> that the image is being called from a database (image sits in images file).
>
> The script in question is this
>
> $image = imagecreatefromjpeg($_GET['src']);
>
> However it produces an error message of
>
> Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: Filename
> cannot be empty in /home/content/a/l/i/alinde52/html/imagesDetail.php on
> line 233
>

First things first.  It looks like there's nothing in $_GET['src'].
>From where are you getting the value 'src'?

Adam


-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php