[PHP] Images can execute php script?

2012-09-23 Thread admin
Today I seen a hack into php that has rocked me to my foundation.
I seen a picture uploaded onto a server using php and when php displayed the
image, phpinfo() was executed and displayed.

Does this problem exist in PHP 5.2.17 +?
How do you stop it?

Sorry, I have never known of this before today.


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



Re: [PHP] Images can execute php script?

2012-09-23 Thread Bastien


Bastien Koert

On 2012-09-23, at 11:57 AM, admin ad...@buskirkgraphics.com wrote:

 Today I seen a hack into php that has rocked me to my foundation.
 I seen a picture uploaded onto a server using php and when php displayed the
 image, phpinfo() was executed and displayed.
 
 Does this problem exist in PHP 5.2.17 +?
 How do you stop it?
 
 Sorry, I have never known of this before today.
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

Jpgs can hold other data rather than image data

One thing to try is to run strip_tags($image) to remove any php code

http://stackoverflow.com/questions/3499173/my-php-site-was-hacked-by-codes-uploaded-as-image

http://josephkeeler.com/2009/04/php-upload-security-the-1x1-jpeg-hack/

Bastien

Re: [PHP] Images can execute php script?

2012-09-23 Thread shiplu
On Sun, Sep 23, 2012 at 9:57 PM, admin ad...@buskirkgraphics.com wrote:

 Today I seen a hack into php that has rocked me to my foundation.
 I seen a picture uploaded onto a server using php and when php displayed
 the
 image, phpinfo() was executed and displayed.

 Does this problem exist in PHP 5.2.17 +?
 How do you stop it?

 Sorry, I have never known of this before today.


How PHP is displaying the image? If it includes then its certainly possible?




-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader


RE: [PHP] Images can execute php script?

2012-09-23 Thread admin
 Jpgs can hold other data rather than image data
 One thing to try is to run strip_tags($image) to remove any php code

http://stackoverflow.com/questions/3499173/my-php-site-was-hacked-by-codes-u
ploaded-as-image
 http://josephkeeler.com/2009/04/php-upload-security-the-1x1-jpeg-hack/
 
 Bastien



I understand the principle behind
include('pages/' . $_GET['page'] . '.php');
http://www.mysite.com/index.php?page=../upload/image.jpg?cmd=somecode%00

Which I find ridiculous if anyone did that.
I am not sure how he was calling the image to be sure. I watched him upload
the image and then
Do what looked like a normal echo UPLOADED_IMAGES.$_FILE[name]; You seen
phpinfo() called but it was not in the script rather in the image.

He opened the test.jpg in a text editor and sure enough there was ?php
phpinfo(); ? in the code of the jpeg.

This bothers me because I am not sure what all he did. He was proving PHP is
not a safe language in front of a rather large group or people in the
meeting.
I could only look on in disbelief that it just happened in front of me.

Everything inside of me wants to say he was doing something outside of what
I consider normal circumstances.
My question is this:
If someone uploads a image through a form or whatever and they have embedded
a code in can that code inside the image be executed by viewing the file?

$image = 'uploaded.jpg';
Echo IMG SRC='.$image.';

Read this:
http://php.webtutor.pl/en/2011/05/13/php-code-injection-a-simple-virus-writt
en-in-php-and-carried-in-a-jpeg-image/
That was written a couple months ago.



 


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



Re: [PHP] Images can execute php script?

2012-09-23 Thread Maciek Sokolewicz

On 23-09-2012 21:30, admin wrote:

Jpgs can hold other data rather than image data
One thing to try is to run strip_tags($image) to remove any php code


http://stackoverflow.com/questions/3499173/my-php-site-was-hacked-by-codes-u
ploaded-as-image

http://josephkeeler.com/2009/04/php-upload-security-the-1x1-jpeg-hack/

Bastien




I understand the principle behind
include('pages/' . $_GET['page'] . '.php');
http://www.mysite.com/index.php?page=../upload/image.jpg?cmd=somecode%00

Which I find ridiculous if anyone did that.
I am not sure how he was calling the image to be sure. I watched him upload
the image and then
Do what looked like a normal echo UPLOADED_IMAGES.$_FILE[name]; You seen
phpinfo() called but it was not in the script rather in the image.

He opened the test.jpg in a text editor and sure enough there was ?php
phpinfo(); ? in the code of the jpeg.

This bothers me because I am not sure what all he did. He was proving PHP is
not a safe language in front of a rather large group or people in the
meeting.
I could only look on in disbelief that it just happened in front of me.

Everything inside of me wants to say he was doing something outside of what
I consider normal circumstances.
My question is this:
If someone uploads a image through a form or whatever and they have embedded
a code in can that code inside the image be executed by viewing the file?



The answer to this is both yes and no. It all depends on:
a) what you do with the file
b) how your webserver is set up / configured

PHP scripts are executed using the PHP interpreter. This means, that for 
a PHP script to be executed, the server needs to:

1. assume the requested file is a PHP script
2. run the PHP interpreter, and provide it the requested file
3. return the output from the PHP interpreter

Most sane servers, when they get a request for a .jpg file, do not 
assume it's a PHP script, and simply return the raw image, which might 
include PHP script, but which will never be run by any sane person.


Some servers however, are configured to run everything through the PHP 
interpreter, before returning its output. In this case: yes, bad stuff 
will happen.


Alternatively, it's possible to run code in files from within other 
files. An example of this was given above, where you showed that 
including a file containing PHP code will execute that code. Regardless 
of what the file is exactly.


In practice I must admit I have very rarely seen this exploit in action, 
since most proper servers and scripts are configured / coded by sane 
enough people for this not to be possible. Unfortunately, if you come 
across a novice coder, (s)he might use the include 'someImage.jpg' 
technique to return images, instead of echo 
file_get_contents('someImage.jpg'), which under these  circumstances is 
a much safer way of doing the same thing.


- Tul

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



[PHP] Re: PHP images server

2010-08-05 Thread Colin Guthrie
'Twas brillig, and Jean-Michel Philippon-Nadeau at 04/08/10 16:48 did
gyre and gimble:
 Hi List,
 
 My website uses a lot of external images coming from many different
 websites. Those images are sometimes small, sometimes big, and to
 reduce the loading time of my pages and for better uniformity, I've
 built a small PHP images server that resizes to a predefined set of
 dimensions the images if necessary. To save on CPU usage, the resized
 version is stored on Amazon AWS.
 
 When requesting an image of a specific size, if the resized image
 exists on AWS, that image is used. The images server then redirects
 the browser to the AWS URL.
 
 I don't believe having 80 redirections is a very clean solution so, my
 question is: How can I optimize my process while keeping the load on
 Amazon's servers?


Presumably you generate the links to the files to put into HTML or CSS
at some point?

Rather than check if an appropriate sized image is available then the
image is requested, why not check when you generate the link to the the
image? If when you generate the link it is NOT available, do the
necessary stuff to generate it and upload to AWS, then carry on.

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



[PHP] PHP images server

2010-08-04 Thread Jean-Michel Philippon-Nadeau
Hi List,

My website uses a lot of external images coming from many different
websites. Those images are sometimes small, sometimes big, and to
reduce the loading time of my pages and for better uniformity, I've
built a small PHP images server that resizes to a predefined set of
dimensions the images if necessary. To save on CPU usage, the resized
version is stored on Amazon AWS.

When requesting an image of a specific size, if the resized image
exists on AWS, that image is used. The images server then redirects
the browser to the AWS URL.

I don't believe having 80 redirections is a very clean solution so, my
question is: How can I optimize my process while keeping the load on
Amazon's servers?

Thanks in advance,

-- 
Jean-Michel

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



Re: [PHP] Images again

2007-04-16 Thread Richard Lynch
On Fri, April 13, 2007 8:02 pm, Børge Holen wrote:
 Before mr lynch starts beating up those already dead and probably long
 since
 burried horses...

 Images in a database!

Feh.

Read the archives.

 See I was just wondering, and that at times leads to late nights
 I used to read the images from two different files; one watermarked
 the image
 and one let it throught without any hazzle.
 Of course this kind of script was easy enought to get around the
 watermarking,
 witch I fixed with the http referer witch as follows IE don't send. I
 don't
 particulary like ppl who use IE (ups did I upset someone?) ;D.

Using referer for anything other than logging it for analysis later
is probably your first mistake...

 However I  started compressing my scripts and putting them inside one
 file.
 And the status is so far:

 * Query for the image object.
 * Query for copyright check in case of watermarking. If no
 watermarking skip
 to echo
 * Read the object.
 * put object in a file outside webroot like /tmp.
 * read both the watermark and object
 * merge
 * echo

 Is it possible to skip one query and still be able to read ownership
 from a
 table and at the same time stream the object, witch lead me to the
 next
 question, I can't seem to be able to make imageCreateFromJPEG handle
 the
 direct stream, nor that I fetch it in an array, is any of this
 possible?

imageCreateFromString should work on your un-watermarked image from
the DB.

When you need the watermark, you can load the watermark from whatever
source you like (file with imagecreatefromjpeg or DB with
imagecreatefromstring)

You can then merge the two images (original and watermark overlay) in
RAM with imagecopymerge calls, or perhaps playing with an alpha blend
with imagealphablending first.

Creating that tmp file and writing/reading to it is probably a pretty
serious performance bottleneck that should be addressed for any kind
of heavy traffic or large images.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Images again

2007-04-16 Thread Børge Holen
On Tuesday 17 April 2007 01:58, Richard Lynch wrote:
 On Fri, April 13, 2007 8:02 pm, Børge Holen wrote:
  Before mr lynch starts beating up those already dead and probably long
  since
  burried horses...
 
  Images in a database!

 Feh.

 Read the archives.

  See I was just wondering, and that at times leads to late nights
  I used to read the images from two different files; one watermarked
  the image
  and one let it throught without any hazzle.
  Of course this kind of script was easy enought to get around the
  watermarking,
  witch I fixed with the http referer witch as follows IE don't send. I
  don't
  particulary like ppl who use IE (ups did I upset someone?) ;D.

 Using referer for anything other than logging it for analysis later
 is probably your first mistake...

Maby so, but it did work with everything but IE ;D.
I seem to have a must try to different approches.


  However I  started compressing my scripts and putting them inside one
  file.
  And the status is so far:
 
  * Query for the image object.
  * Query for copyright check in case of watermarking. If no
  watermarking skip
  to echo
  * Read the object.
  * put object in a file outside webroot like /tmp.
  * read both the watermark and object
  * merge
  * echo
 
  Is it possible to skip one query and still be able to read ownership
  from a
  table and at the same time stream the object, witch lead me to the
  next
  question, I can't seem to be able to make imageCreateFromJPEG handle
  the
  direct stream, nor that I fetch it in an array, is any of this
  possible?

 imageCreateFromString should work on your un-watermarked image from
 the DB.

Yeah, perfectly


 When you need the watermark, you can load the watermark from whatever
 source you like (file with imagecreatefromjpeg or DB with
 imagecreatefromstring)

 You can then merge the two images (original and watermark overlay) in
 RAM with imagecopymerge calls, or perhaps playing with an alpha blend
 with imagealphablending first.

already fixed with an transparent gif.


 Creating that tmp file and writing/reading to it is probably a pretty
 serious performance bottleneck that should be addressed for any kind
 of heavy traffic or large images.

So I noticed, I'm also thinkering with a filsystem (using /tmp) as cache for 
the merged images. Not really useful since cuz of the few users, but then 
again, why not try. 


 --
 Some people have a gift link here.
 Know what I want?
 I want you to buy a CD from some indie artist.
 http://cdbaby.com/browse/from/lynch
 Yeah, I get a buck. So?

-- 
---
Børge
http://www.arivene.net
---

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



Re: [PHP] Images again

2007-04-14 Thread Tijnema !

On 4/14/07, Børge Holen [EMAIL PROTECTED] wrote:

Before mr lynch starts beating up those already dead and probably long since
burried horses...

Images in a database!

See I was just wondering, and that at times leads to late nights
I used to read the images from two different files; one watermarked the image
and one let it throught without any hazzle.
Of course this kind of script was easy enought to get around the watermarking,
witch I fixed with the http referer witch as follows IE don't send. I don't
particulary like ppl who use IE (ups did I upset someone?) ;D.


Hmm, nearly I use IE, NOT because i like it, but because i hate
the others more (On windows platform).



However I  started compressing my scripts and putting them inside one file.
And the status is so far:

* Query for the image object.
* Query for copyright check in case of watermarking. If no watermarking skip
to echo
* Read the object.
* put object in a file outside webroot like /tmp.
* read both the watermark and object
* merge
* echo

Is it possible to skip one query and still be able to read ownership from a
table and at the same time stream the object, witch lead me to the next
question, I can't seem to be able to make imageCreateFromJPEG handle the
direct stream, nor that I fetch it in an array, is any of this possible?


You should fetch the stream manually in a string, and then use
imagecreatefromstring, http://www.php.net/imagecreatefromstring



As of now I need two files to make this happen. Either I use one file to check
for rights and download throught a second file (close to the old solution) or
I try this new thing and end up with one php file witch needs the object
stream to be saved before it can be managed proberly.

--
---
Børge
http://www.arivene.net


For the rest of your message, i don't understand what you're trying to
do. Show us (parts of) the code you have now, and then explain what
you've wanted to do, and what it does now.

Tijnema

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



Re: [PHP] Images again

2007-04-14 Thread Børge Holen
On Saturday 14 April 2007 09:45, you wrote:
 On 4/14/07, Børge Holen [EMAIL PROTECTED] wrote:
  Before mr lynch starts beating up those already dead and probably long
  since burried horses...
 
  Images in a database!
 
  See I was just wondering, and that at times leads to late nights
  I used to read the images from two different files; one watermarked the
  image and one let it throught without any hazzle.
  Of course this kind of script was easy enought to get around the
  watermarking, witch I fixed with the http referer witch as follows IE
  don't send. I don't particulary like ppl who use IE (ups did I upset
  someone?) ;D.

 Hmm, nearly I use IE, NOT because i like it, but because i hate
 the others more (On windows platform).
 
Sounds so unlikely, didn't know anyone used that crap anymore... I thought 
everyone switched to tiger linux opensolaris aros etc when viste came out. ;D


  However I  started compressing my scripts and putting them inside one
  file. And the status is so far:
 
  * Query for the image object.
  * Query for copyright check in case of watermarking. If no watermarking
  skip to echo
  * Read the object.
  * put object in a file outside webroot like /tmp.
  * read both the watermark and object
  * merge
  * echo
 
  Is it possible to skip one query and still be able to read ownership from
  a table and at the same time stream the object, witch lead me to the next
  question, I can't seem to be able to make imageCreateFromJPEG handle the
  direct stream, nor that I fetch it in an array, is any of this possible?

 You should fetch the stream manually in a string, and then use
 imagecreatefromstring, http://www.php.net/imagecreatefromstring

YES FREAKIN PERFECT.


  As of now I need two files to make this happen. Either I use one file to
  check for rights and download throught a second file (close to the old
  solution) or I try this new thing and end up with one php file witch
  needs the object stream to be saved before it can be managed proberly.
 
  --
  ---
  Børge
  http://www.arivene.net

 For the rest of your message, i don't understand what you're trying to
 do. Show us (parts of) the code you have now, and then explain what
 you've wanted to do, and what it does now.

Just me blabbering in frustration...
my code is now pretty simple. one connection, one query, two results,
checks if image is copyrighted.  Then with your contribution, prints with or 
without the watermark.


 Tijnema

Thanks

-- 
---
Børge
http://www.arivene.net
---

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



[PHP] Images again

2007-04-13 Thread Børge Holen
Before mr lynch starts beating up those already dead and probably long since 
burried horses...

Images in a database!

See I was just wondering, and that at times leads to late nights
I used to read the images from two different files; one watermarked the image 
and one let it throught without any hazzle.
Of course this kind of script was easy enought to get around the watermarking, 
witch I fixed with the http referer witch as follows IE don't send. I don't 
particulary like ppl who use IE (ups did I upset someone?) ;D.

However I  started compressing my scripts and putting them inside one file. 
And the status is so far:

* Query for the image object.
* Query for copyright check in case of watermarking. If no watermarking skip 
to echo
* Read the object.
* put object in a file outside webroot like /tmp.
* read both the watermark and object
* merge
* echo

Is it possible to skip one query and still be able to read ownership from a 
table and at the same time stream the object, witch lead me to the next 
question, I can't seem to be able to make imageCreateFromJPEG handle the 
direct stream, nor that I fetch it in an array, is any of this possible?

As of now I need two files to make this happen. Either I use one file to check 
for rights and download throught a second file (close to the old solution) or 
I try this new thing and end up with one php file witch needs the object 
stream to be saved before it can be managed proberly.

-- 
---
Børge
http://www.arivene.net
---

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



[PHP] Images outside webroot + session = safe?

2005-10-29 Thread Joseph Tura
Hi there,

I am storing images outside the webroot to keep them from being accessible
for unauthorized users to see.

Then I use a script to show the images, like this:

img src=show.php

Now, as there is no information on the images stored in a database yet (they
have just been uploaded via ftp), I need to find a way of passing the
information as to which image is to be displayed.

I am currently trying out this way:

1. I read the filenames for all images in the upload directory into an
array.
2. I store that array in a session variable.
$_SESSION['images'] = $this-image_array;

3. I call show.php passing an array key:

img src=show.php?id=xy

4. In show.php I start the session, get the image information from the
session array, check if the mime type is okay and then display the image.

Of course I still need to add user authorization... 

Any opinions on how safe this method seems or how it could be made
safer/more efficient? Do you think this method could be exploited to
compromise the server in any way?

Here the listing for show.php

?php
session_start();

$file = $_SESSION['images'][$_GET['id']];

if(is_file($file['path'].$file['file'])) {
  //determine mime type and imagetype
  $tmp = getimagesize($file['path'].$file['file']);
  $file['mime'] = $tmp['mime'];
  
  //if file is of valid type - output to browser
  if(in_array($file['mime'], $_SESSION['conf']['images']['allowedtypes'])) {
header(Content-Type: .$file['mime']);
header(Content-Disposition: filename=.$file['name']);
readfile($file['path'].$file['file']);
  }
}
?

Any comments are appreciated.

jt

-- 
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner

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



Re: [PHP] Images - Converting TIFF Format?

2005-04-20 Thread The Disguised Jedi
I searched through my server's system (I'm not running it, it's my ISP) and 
finally found that TIFF isn't compiled into GD. I can get them to do it, but 
I need to know what functions to use! Are they under a different file type? 
I'm pretty sure I searched through thoroughly for the function. Did I miss 
something?
 Thanks for all your help!

 On 4/19/05, Tom Rogers [EMAIL PROTECTED] wrote: 
 
 Hi,
 
 Wednesday, April 20, 2005, 12:39:54 AM, you wrote:
 TDJ Is there a quick way to convert a TIFF format picture to a GIF 
 quickly? I
 TDJ can only find support for GIFs in PHP, but maybe I'm missing 
 something. I
 TDJ have a client running a photography business, and I have designed an 
 image
 TDJ watermark and resizing engine, and a server to check the request, 
 serve the
 TDJ file, and then delete it. I mainly made this to help him run the site
 TDJ himself, since he isn't very good with Photoshop, and can't watermark 
 the
 TDJ images (I shouldn't say that...he probably could, but not very 
 fastbut
 TDJ anyway...).
 TDJ This is all working fine and dandy, but the system will only accept 
 GIF
 TDJ format. His images are all raw scans in TIFF format. This means that 
 he has
 TDJ to open the image in Photoshop, resize it, and convert it to a GIF. I 
 think
 TDJ he can do this himself, but I'd like to make it even simpler, which 
 is why
 TDJ I'm writing.
 TDJ I need a quick way, preferably in PHP, but it doesn't have to be, to
 TDJ convert large batches of TIFF format images to GIF. Does anyone know 
 of a
 TDJ way to do this?
 TDJ Thanks for reading, and for your responses in advance...
 
 I use netpbm for conversion to png from tiffs and windows bitmaps like 
 this:
 
 //$tempname from fileupload tmpname
 //$file from fileupload name
 $jobpath = '/wherever/you/want/files/stored';
 if($im = getimagesize($tempname)){
 if($im[0]  0){
 //cleanup filename
 $file = ereg_replace(',,$file);
 $file = ereg_replace(%20,_,$file);
 $file = ereg_replace( ,_,$file);
 $ext = @substr($file, (@strrpos($file, .) ? @strrpos($file, .) + 1 : 
 @strlen($file)), @strlen($file));
 $fname = basename($file,$ext);
 switch(intval($im[2])){
 case 7:
 case 8:
 //force a tif extension for netpbm
 $tfilename = $jobpath.'/'.$fname.'tif';
 move_uploaded_file($tempname, $tfilename);
 $file = $fname.'png';
 $filename = $jobpath.'/'.$file;
 shell_exec (/path/to/netpbm/bin/tifftopnm -quiet $tfilename | 
 /path/to/netpbm/bin/pnmtopng  $filename);
 break;
 case 6:
 //force a bmp extension for netpbm
 $tfilename = $jobpath.'/'.$fname.'bmp';
 move_uploaded_file($tempname, $tfilename);
 $file = $fname.'png';
 $filename = $jobpath.'/'.$file;
 shell_exec (/path/to/netpbm/bin/bmptoppm -quiet $tfilename | 
 /path/to/netpbm/bin/pnmtopng  $filename);
 break;
 default:
 $filename = $jobpath.'/'.$file;
 move_uploaded_file($tempname, $filename);
 break;
 }
 }
 }
 
 --
 regards,
 Tom
 
 


-- 
The Disguised Jedi
[EMAIL PROTECTED]

Now you have my $0.02. Or .01 Pounds, .014 Euros, or $0.025 CAN. I'm 
world-wide BABY!
PHP rocks!
Knowledge is Power. Power Corrupts. Go to school, become evil

Disclaimer: Any disclaimer attached to this message may be ignored. However, 
I must say that the ENTIRE contents of this message are subject to other's 
criticism, corrections, and speculations.

This message is Certified Virus Free


Re[2]: [PHP] Images - Converting TIFF Format?

2005-04-20 Thread Tom Rogers
Hi,

Thursday, April 21, 2005, 3:15:31 AM, you wrote:
TDJ I searched through my server's system (I'm not running it, it's my ISP) and
TDJ finally found that TIFF isn't compiled into GD. I can get them to do it, 
but
TDJ I need to know what functions to use! Are they under a different file type?
TDJ I'm pretty sure I searched through thoroughly for the function. Did I miss
TDJ something?
TDJ  Thanks for all your help!

As far as I know gd does not support tiffs directly.

-- 
regards,
Tom

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



[PHP] Images - Converting TIFF Format?

2005-04-19 Thread The Disguised Jedi
Is there a quick way to convert a TIFF format picture to a GIF quickly? I 
can only find support for GIFs in PHP, but maybe I'm missing something. I 
have a client running a photography business, and I have designed an image 
watermark and resizing engine, and a server to check the request, serve the 
file, and then delete it. I mainly made this to help him run the site 
himself, since he isn't very good with Photoshop, and can't watermark the 
images (I shouldn't say that...he probably could, but not very fastbut 
anyway...).
 This is all working fine and dandy, but the system will only accept GIF 
format. His images are all raw scans in TIFF format. This means that he has 
to open the image in Photoshop, resize it, and convert it to a GIF. I think 
he can do this himself, but I'd like to make it even simpler, which is why 
I'm writing.
 I need a quick way, preferably in PHP, but it doesn't have to be, to 
convert large batches of TIFF format images to GIF. Does anyone know of a 
way to do this?
 Thanks for reading, and for your responses in advance...

-- 
The Disguised Jedi
[EMAIL PROTECTED]

Now you have my $0.02. Or .01 Pounds, .014 Euros, or $0.025 CAN. I'm 
world-wide BABY!
PHP rocks!
Knowledge is Power. Power Corrupts. Go to school, become evil

Disclaimer: Any disclaimer attached to this message may be ignored. However, 
I must say that the ENTIRE contents of this message are subject to other's 
criticism, corrections, and speculations.

This message is Certified Virus Free


Re: [PHP] Images - Converting TIFF Format?

2005-04-19 Thread Richard Lynch
On Tue, April 19, 2005 7:39 am, The Disguised Jedi said:
 Is there a quick way to convert a TIFF format picture to a GIF quickly? I

I'm reasonably certain you can get GD to read TIFF files, if you install
TIFF on your server, and then the GD extension again...

Start reading at http://php.net/gd to be sure.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Images - Converting TIFF Format?

2005-04-19 Thread Tom Rogers
Hi,

Wednesday, April 20, 2005, 12:39:54 AM, you wrote:
TDJ Is there a quick way to convert a TIFF format picture to a GIF quickly? I
TDJ can only find support for GIFs in PHP, but maybe I'm missing something. I
TDJ have a client running a photography business, and I have designed an image
TDJ watermark and resizing engine, and a server to check the request, serve the
TDJ file, and then delete it. I mainly made this to help him run the site
TDJ himself, since he isn't very good with Photoshop, and can't watermark the
TDJ images (I shouldn't say that...he probably could, but not very fastbut
TDJ anyway...).
TDJ  This is all working fine and dandy, but the system will only accept GIF
TDJ format. His images are all raw scans in TIFF format. This means that he has
TDJ to open the image in Photoshop, resize it, and convert it to a GIF. I think
TDJ he can do this himself, but I'd like to make it even simpler, which is why
TDJ I'm writing.
TDJ  I need a quick way, preferably in PHP, but it doesn't have to be, to
TDJ convert large batches of TIFF format images to GIF. Does anyone know of a
TDJ way to do this?
TDJ  Thanks for reading, and for your responses in advance...


I use netpbm for conversion to png from tiffs and windows bitmaps like this:

//$tempname from fileupload tmpname
//$file from fileupload name
$jobpath = '/wherever/you/want/files/stored';
if($im = getimagesize($tempname)){
  if($im[0]  0){
//cleanup filename  
$file = ereg_replace(',,$file);
$file = ereg_replace(%20,_,$file);
$file = ereg_replace( ,_,$file);
$ext = @substr($file, (@strrpos($file, .) ? @strrpos($file, .) + 1 : 
@strlen($file)), @strlen($file));
$fname = basename($file,$ext);
switch(intval($im[2])){
  case 7:
  case 8:
//force a tif extension for netpbm
$tfilename = $jobpath.'/'.$fname.'tif';
move_uploaded_file($tempname, $tfilename);
$file = $fname.'png';
$filename = $jobpath.'/'.$file;
shell_exec (/path/to/netpbm/bin/tifftopnm -quiet $tfilename | 
/path/to/netpbm/bin/pnmtopng  $filename);
  break;
  case 6:
//force a bmp extension for netpbm
$tfilename = $jobpath.'/'.$fname.'bmp';
move_uploaded_file($tempname, $tfilename);
$file = $fname.'png';
$filename = $jobpath.'/'.$file;
shell_exec (/path/to/netpbm/bin/bmptoppm -quiet $tfilename | 
/path/to/netpbm/bin/pnmtopng  $filename);
  break;
  default:
$filename = $jobpath.'/'.$file;
move_uploaded_file($tempname, $filename);
  break;
}
  }
}

-- 
regards,
Tom

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



Re: [PHP] images process

2004-11-21 Thread edwardspl
Yes, I need a sample ( display images with php directly from database )
for reference...
So, can you help me ?

Many thank for your help !

Raditha Dissanayake wrote:

 [EMAIL PROTECTED] wrote:

 So, how can we fix this kind of problem ?
 
 
 is it a problem?

 Raditha Dissanayake wrote:
 
 
 
 [EMAIL PROTECTED] wrote:
 
 
 
 Dear You,
 
 How to load images ( eg: gif, jpg) with base64 function from
 Database on IE directly ?
 
 
 
 
 as far as I know you cannot do this with IE directly.
 
 
 
 Is there any samples to me for reference ?
 
 Many thank for your help !
 
 Ed.
 
 
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 

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

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



Re: [PHP] images process

2004-11-21 Thread Paul Furman
You need to set up an apache server  get that running on your windows
machine in order to run php. Then you go thru IE to view the php script
 run it that way.


[EMAIL PROTECTED] wrote:

 Yes, I need a sample ( display images with php directly from database )
 for reference...
 So, can you help me ?
 
 Many thank for your help !
 
 Raditha Dissanayake wrote:
 
 
[EMAIL PROTECTED] wrote:


So, how can we fix this kind of problem ?



is it a problem?


Raditha Dissanayake wrote:




[EMAIL PROTECTED] wrote:




Dear You,

How to load images ( eg: gif, jpg) with base64 function from
Database on IE directly ?





as far as I know you cannot do this with IE directly.




Is there any samples to me for reference ?

Many thank for your help !

Ed.






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





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

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



Re: [PHP] images process

2004-11-21 Thread James Cartledge
On Sun, 21 Nov 2004 22:22:52 +0800, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 Yes, I need a sample ( display images with php directly from database )
 for reference...
 So, can you help me ?
 
 
 
 Many thank for your help !
 

Does this help?
http://www.onlamp.com/pub/a/onlamp/2002/05/09/webdb2.html
google: php image database

J.

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



Re: [PHP] images process

2004-11-21 Thread edwardspl
Sorry,

I need a sample of php program...

Thanks!

Paul Furman wrote:

 You need to set up an apache server  get that running on your windows
 machine in order to run php. Then you go thru IE to view the php script
  run it that way.

 [EMAIL PROTECTED] wrote:

  Yes, I need a sample ( display images with php directly from database )
  for reference...
  So, can you help me ?
 
  Many thank for your help !
 
  Raditha Dissanayake wrote:
 
 
 [EMAIL PROTECTED] wrote:
 
 
 So, how can we fix this kind of problem ?
 
 
 
 is it a problem?
 
 
 Raditha Dissanayake wrote:
 
 
 
 
 [EMAIL PROTECTED] wrote:
 
 
 
 
 Dear You,
 
 How to load images ( eg: gif, jpg) with base64 function from
 Database on IE directly ?
 
 
 
 
 
 as far as I know you cannot do this with IE directly.
 
 
 
 
 Is there any samples to me for reference ?
 
 Many thank for your help !
 
 Ed.
 
 
 
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

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

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



Re: [PHP] images process

2004-11-21 Thread James Cartledge
On Mon, 22 Nov 2004 09:13:14 +0800, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 Sorry,
 
 I need a sample of php program...
 
 Thanks!
 
 

Does this help?
http://www.onlamp.com/pub/a/onlamp/2002/05/09/webdb2.html
google: php image database

J.

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



Re: [PHP] images process

2004-11-21 Thread Raditha Dissanayake
[EMAIL PROTECTED] wrote:

Sorry,

I need a sample of php program...
  

They are dime a dozen on google.
please trim your posts.

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



[PHP] images process

2004-11-20 Thread edwardspl
Dear You,

How to load images ( eg: gif, jpg) with base64 function from
Database on IE directly ?
Is there any samples to me for reference ?

Many thank for your help !

Ed.

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



Re: [PHP] images process

2004-11-20 Thread Raditha Dissanayake
[EMAIL PROTECTED] wrote:

Dear You,

How to load images ( eg: gif, jpg) with base64 function from
Database on IE directly ?
  

as far as I know you cannot do this with IE directly.

Is there any samples to me for reference ?

Many thank for your help !

Ed.

  


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



Re: [PHP] images process

2004-11-20 Thread edwardspl
So, how can we fix this kind of problem ?

Raditha Dissanayake wrote:

 [EMAIL PROTECTED] wrote:

 Dear You,
 
 How to load images ( eg: gif, jpg) with base64 function from
 Database on IE directly ?
 
 
 as far as I know you cannot do this with IE directly.

 Is there any samples to me for reference ?
 
 Many thank for your help !
 
 Ed.
 
 
 

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

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



Re: [PHP] images process

2004-11-20 Thread Raditha Dissanayake
[EMAIL PROTECTED] wrote:

So, how can we fix this kind of problem ?
  

is it a problem?

Raditha Dissanayake wrote:

  

[EMAIL PROTECTED] wrote:



Dear You,

How to load images ( eg: gif, jpg) with base64 function from
Database on IE directly ?


  

as far as I know you cannot do this with IE directly.



Is there any samples to me for reference ?

Many thank for your help !

Ed.



  

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



  


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



[PHP] Images problem

2004-11-17 Thread Phpu
If i have 2 images:

$im1 = imagecreate (100, 100); 
$white = ImageColorAllocate ($im1, 255, 255, 255);


$im2 = imagecreate (50, 50); 
$black = ImageColorAllocate ($im2, 0, 0, 0);


How can i put $im2 over $im1 and result one single image? Is there a function 
to do this?

Thank You

Re: [PHP] Images problem

2004-11-17 Thread Randy Rinehart
I believe you can use imagecopymerged to do this.

http://us2.php.net/manual/en/function.imagecopymerge.php

please let me know if that helps.

Thanks

-randy rinehart

- Original Message - 
From: Phpu [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, November 17, 2004 10:05 AM
Subject: [PHP] Images problem


If i have 2 images:

$im1 = imagecreate (100, 100);
$white = ImageColorAllocate ($im1, 255, 255, 255);


$im2 = imagecreate (50, 50);
$black = ImageColorAllocate ($im2, 0, 0, 0);


How can i put $im2 over $im1 and result one single image? Is there a
function to do this?

Thank You

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



Re: [PHP] Images problem

2004-11-17 Thread Eakin, W
Phpu wrote:
If i have 2 images:
$im1 = imagecreate (100, 100); 
$white = ImageColorAllocate ($im1, 255, 255, 255);

$im2 = imagecreate (50, 50); 
$black = ImageColorAllocate ($im2, 0, 0, 0);

How can i put $im2 over $im1 and result one single image? Is there a 
function to do this?
Thank You
 

this looks like what you need
http://www.php.net/manual/en/function.imagecopymerge.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Images problem

2004-11-17 Thread Mike
If you're looking for a way to merge images, look at imagecopyresized()

If you're going to be doing a lot with images in PHP, it's good to spend a
lot of time reading the images section of the manual - there's a lot in
there and all with somewhat similar names - it can get confusing at first.

-M 

-Original Message-
From: Phpu [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, November 17, 2004 11:05 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Images problem

If i have 2 images:

$im1 = imagecreate (100, 100); 
$white = ImageColorAllocate ($im1, 255, 255, 255);


$im2 = imagecreate (50, 50); 
$black = ImageColorAllocate ($im2, 0, 0, 0);


How can i put $im2 over $im1 and result one single image? Is there a
function to do this?

Thank You

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



Re: [PHP] Images problem

2004-11-17 Thread Phpu
It's working  Thanks a lot


- Original Message - 
From: Randy Rinehart [EMAIL PROTECTED]
To: Phpu [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, November 17, 2004 6:29 PM
Subject: Re: [PHP] Images problem


 I believe you can use imagecopymerged to do this.
 
 http://us2.php.net/manual/en/function.imagecopymerge.php
 
 please let me know if that helps.
 
 Thanks
 
 -randy rinehart
 
 - Original Message - 
 From: Phpu [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, November 17, 2004 10:05 AM
 Subject: [PHP] Images problem
 
 
 If i have 2 images:
 
 $im1 = imagecreate (100, 100);
 $white = ImageColorAllocate ($im1, 255, 255, 255);
 
 
 $im2 = imagecreate (50, 50);
 $black = ImageColorAllocate ($im2, 0, 0, 0);
 
 
 How can i put $im2 over $im1 and result one single image? Is there a
 function to do this?
 
 Thank You
 
 

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



RE: [PHP] images doesn't seem to cache

2004-11-09 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 06 November 2004 20:09, anders thoresson wrote:

   This code seems to work. Have I got it right?
 
   No. I have not. Sometimes the images are viewed from the
 cache, just
 to get downloaded from the server again next time, just a
 minute later,
 when I try again.
 
   My local development server is running IIS, my production server is
 running Apache. Where is the best place to look for If-Modified-Since?
 Is $_GET['If-Modified-Since'] a safe bet?

For Apache, I found it in $_SERVER['HTTP_IF_MODIFIED_SINCE']; if IIS passes
it to PHP, I would definitely expect it to be in $_SERVER[].

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] images doesn't seem to cache

2004-11-08 Thread Marek Kilimajer
anders thoresson wrote:
 This code seems to work. Have I got it right?

 No. I have not. Sometimes the images are viewed from the cache, just to 
get downloaded from the server again next time, just a minute later, 
when I try again.

 My local development server is running IIS, my production server is 
running Apache. Where is the best place to look for If-Modified-Since? 
Is $_GET['If-Modified-Since'] a safe bet?
No, it's a http header, not a get parameter. I'm not sure if this header 
is made available under IIS. Under apache you could use 
apache_request_headers().

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


Re: [PHP] images doesn't seem to cache

2004-11-07 Thread anders thoresson
it won't be a php-parameter. Seen as the script isn't executed when the 
server decides it is the same as the cached version. So only if it deems 
not to be, then it runs the script, and when it does that, the script 
doesn't need to know anything about modified-since, because that checks 
has long since been passed.
 Really? It's not until the script is executed that the acutal image is 
accessed. Until, it's only refered to as a picture id, and int-value.

 Your suggestion was to use If-Modified-Since. How and where should I 
do a check for it?

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


Re: [PHP] images doesn't seem to cache

2004-11-06 Thread anders thoresson
Your eyes are fine. You need to check for If-Modified-Since header, if 
the time is older than file modification time (filemtime()) send 
Last-Modified header and the image, else send 304 Not Modified response.
 This code seems to work. Have I got it right?
// Get the time the cache file was last modified
$lastModified = filemtime($pPath);
// Issue an HTTP last modified header
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $lastModified) . ' 
GMT');

if (isset($_GET['If-Modified-Since']))
{
// Split the If-Modified-Since (Netscape  v6 gets this wrong)
$modifiedSince = explode(';', $_GET['If-Modified-Since']);

// Turn the client request If-Modified-Since into a timestamp
$modifiedSince = strtotime($modifiedSince[0]);
}
else
{
$modifiedSince = 0;
}
// Compare time the content was last modified with client cache
if ($lastModified = $modifiedSince)
{
header('HTTP/1.1 304 Not Modified');
}
else
{
$extention = substr($path, -3);
if ($extention == jpg)
header(Content-type: image/jpeg);
if ($extention == gif)
header(Content-type: image/gif);
if ($extention == bmp)
header(Content-type: image/bmp);
if ($extention == png)
header(Content-type: image/png);
readfile($pPath);
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] images doesn't seem to cache

2004-11-06 Thread anders thoresson
 This code seems to work. Have I got it right?
 No. I have not. Sometimes the images are viewed from the cache, just 
to get downloaded from the server again next time, just a minute later, 
when I try again.

 My local development server is running IIS, my production server is 
running Apache. Where is the best place to look for If-Modified-Since? 
Is $_GET['If-Modified-Since'] a safe bet?

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


Re: [PHP] images doesn't seem to cache

2004-11-06 Thread M. Sokolewicz
Anders Thoresson wrote:
 This code seems to work. Have I got it right?

 No. I have not. Sometimes the images are viewed from the cache, just to 
get downloaded from the server again next time, just a minute later, 
when I try again.

 My local development server is running IIS, my production server is 
running Apache. Where is the best place to look for If-Modified-Since? 
Is $_GET['If-Modified-Since'] a safe bet?
it won't be a php-parameter. Seen as the script isn't executed when the 
server decides it is the same as the cached version. So only if it deems 
not to be, then it runs the script, and when it does that, the script 
doesn't need to know anything about modified-since, because that checks 
has long since been passed.

This is all an issue between browser and server, and php can't interfere 
in between those. However, to do something about it, change the headers 
that you send abou caching. These are the pragma headers for HTTP/1.0 
(?), and the Cache-Control headers in HTTP/1.1


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


[PHP] images doesn't seem to cache

2004-11-05 Thread anders thoresson
Hi,
I put all my images outside the web root, the prevent direct access, and 
then access them with a img-tag like this:

img src=fnc_get_image.php?path=?=$path;? /
where fnc_get_image.php is:
// Check if user is logged in
require_once 'global_includes.php';
$user = new User();
// Get path to image for display
$path = $_GET['path'];
// Prepend path - prevents misuse
$pPath = /home/username/albums/ . $path;
header(Cache-Control: private);
$extention = substr($path, -3);
if ($extention == jpg)
header(Content-type: image/jpeg);
if ($extention == gif)
header(Content-type: image/gif);
if ($extention == bmp)
header(Content-type: image/bmp);
if ($extention == png)
header(Content-type: image/png);
readfile($pPath);
There is one slight problem though: To my eyes, it looks like the images
are downloaded from the server every time. Is this a side effect of this
method or is it just a optical illusion? Is there a way to tell for sure
if the image is downloaded or displayed from the browser cache?
I've tried with and without a Cache-Control header. It doesn't seem to 
do any difference at all.

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


Re: [PHP] images doesn't seem to cache

2004-11-05 Thread Marek Kilimajer
anders thoresson wrote:
Hi,
I put all my images outside the web root, the prevent direct access, and 
then access them with a img-tag like this:

img src=fnc_get_image.php?path=?=$path;? /
where fnc_get_image.php is:
// Check if user is logged in
require_once 'global_includes.php';
$user = new User();
// Get path to image for display
$path = $_GET['path'];
// Prepend path - prevents misuse
$pPath = /home/username/albums/ . $path;
header(Cache-Control: private);
$extention = substr($path, -3);
if ($extention == jpg)
header(Content-type: image/jpeg);
if ($extention == gif)
header(Content-type: image/gif);
if ($extention == bmp)
header(Content-type: image/bmp);
if ($extention == png)
header(Content-type: image/png);
readfile($pPath);
There is one slight problem though: To my eyes, it looks like the images
are downloaded from the server every time. Is this a side effect of this
method or is it just a optical illusion? Is there a way to tell for sure
if the image is downloaded or displayed from the browser cache?
I've tried with and without a Cache-Control header. It doesn't seem to 
do any difference at all.
Your eyes are fine. You need to check for If-Modified-Since header, if 
the time is older than file modification time (filemtime()) send 
Last-Modified header and the image, else send 304 Not Modified response.

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


RE: [PHP] Images in PHP and MySQL

2004-10-06 Thread Ed Lazor
 On Friday 01 October 2004 05:52, Ed Lazor wrote:
  Images take up more space when stored in the db, because you're storing
 raw
  binary data.  Gif and jpeg are compression methods that convert binary
 data
  into something smaller that can be stored in a file.
 
 ??
 
 If you store a jpeg file into a database blob, the database doesn't
 magically
 decompress the jpeg file. It will just treat the jpeg file as any other
 binary file and store it as-is (plus any overhead).

Sorry for not responding sooner - just found this message while cleaning on
my PHP folder.

Anyway, we're both right, depending on how you go about saving the images to
the database.  You're talking about using PHP's file functions to open the
image file, read in the data, and stream it to the database.  I'm talking
about using the built-in GD functions to grab the image (like
imagecreatefromjpeg) and store it into the database.

As you're pointing out, the GD functions are performing the compression and
decompression.

This was part of another discussion GH and I were having on the MySQL list
about different approaches to storing large collections of images.  Sorry, I
should have mentioned that.

-Ed

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



Re: [PHP] Images in PHP and MySQL

2004-10-06 Thread Gary Hotko
No problem Ed thanks...

Actually I was supprised to see this conversation (thread) come back
into my GMAIL inbox


On Wed, 6 Oct 2004 15:57:12 -0700, Ed Lazor [EMAIL PROTECTED] wrote:
  On Friday 01 October 2004 05:52, Ed Lazor wrote:
   Images take up more space when stored in the db, because you're storing
  raw
   binary data.  Gif and jpeg are compression methods that convert binary
  data
   into something smaller that can be stored in a file.
 
  ??
 
  If you store a jpeg file into a database blob, the database doesn't
  magically
  decompress the jpeg file. It will just treat the jpeg file as any other
  binary file and store it as-is (plus any overhead).
 
 Sorry for not responding sooner - just found this message while cleaning on
 my PHP folder.
 
 Anyway, we're both right, depending on how you go about saving the images to
 the database.  You're talking about using PHP's file functions to open the
 image file, read in the data, and stream it to the database.  I'm talking
 about using the built-in GD functions to grab the image (like
 imagecreatefromjpeg) and store it into the database.
 
 As you're pointing out, the GD functions are performing the compression and
 decompression.
 
 This was part of another discussion GH and I were having on the MySQL list
 about different approaches to storing large collections of images.  Sorry, I
 should have mentioned that.
 
 -Ed
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP] Images in PHP and MySQL

2004-09-30 Thread Jasper Howard
If you're uploading a file then you can make a script that reads the
temp file into the database (otherwise you need to muck around with
image functions and I'm not the one to ask about that), something
like:

$image = mysql_escape_string(fread(fopen($_FILES['file']['tmp_name'],
r), filesize($_FILES['file']['tmp_name'])));

Then you just put $image in the db under a BLOG field type. This is
what I did when I needed to save some images to a db and it seemed to
work fine. Make sure you save the file type to the database so you can
display the image properly. When you are ready to display an image,
just create the html for an image and set the source to a php script
that will output the image:

img src=scripts/display_image.php?id=1

And in the display_image.php script do something like this:

?
...DB QUERY...

$type = $row['file_type'];
$dfile = $row['file_data'];
header(Content-Type: $type);
header(Content-Disposition: filename=.basename($dfile).;);
header(Content-Length: .filesize($dfile));
readfile($dfile);
exit;
?

That code was modified a bit from its origional function (forcing
download of the file) but I think it should just work, but there's
always the chance I messed it up somehow.

hope that works for someone,
-Jasper Howard


On Mon, 27 Sep 2004 19:05:16 -0500, Jim Grill [EMAIL PROTECTED] wrote:
  1) there is no need to fiddle with directory permissions to write images.
  2) if the content is sensitive you have the added security of the database
  password (and the fact that the database is ususally not directly
  accessible).
  3) a mysqldump gives a backup of all images along with other persistent
 data
 
  Other disadvantages follow:
  1) excessive load on the server for loading each image
  2) the load mentioned above causes a slow down in the script
  3) images usually need to be written to file before using GD for
  manipulation, inclusion in PDFs, etc.
 
 That's a very good list.
 
 I just wanted to pipe in on this one thing:
 
 3) images usually need to be written to file before using GD for
 manipulation, inclusion in PDFs, etc.
 
 There is actually a function for this: imagecreatefromstring()
 
 I'll don't want to touch the rest of this topic though. :-)
 
 Jim Grill
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 



-- 

Jasper Howard - Database Administration
ApexEleven.com
530 559 0107
---

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



Re: [PHP] Images in PHP and MySQL

2004-09-30 Thread GH
HEre is a question that I have been wondering about:

   - Does the image file use more space in the db or as a file itself
(Do Not count the extra data that one would store in the db along with
the image... ie. ID number)

Thanks


On Thu, 30 Sep 2004 09:55:30 -0700, Jasper Howard [EMAIL PROTECTED] wrote:
 If you're uploading a file then you can make a script that reads the
 temp file into the database (otherwise you need to muck around with
 image functions and I'm not the one to ask about that), something
 like:
 
 $image = mysql_escape_string(fread(fopen($_FILES['file']['tmp_name'],
 r), filesize($_FILES['file']['tmp_name'])));
 
 Then you just put $image in the db under a BLOG field type. This is
 what I did when I needed to save some images to a db and it seemed to
 work fine. Make sure you save the file type to the database so you can
 display the image properly. When you are ready to display an image,
 just create the html for an image and set the source to a php script
 that will output the image:
 
 img src=scripts/display_image.php?id=1
 
 And in the display_image.php script do something like this:
 
 ?
 ...DB QUERY...
 
 $type = $row['file_type'];
 $dfile = $row['file_data'];
 header(Content-Type: $type);
 header(Content-Disposition: filename=.basename($dfile).;);
 header(Content-Length: .filesize($dfile));
 readfile($dfile);
 exit;
 ?
 
 That code was modified a bit from its origional function (forcing
 download of the file) but I think it should just work, but there's
 always the chance I messed it up somehow.
 
 hope that works for someone,
 -Jasper Howard
 
 
 
 
 On Mon, 27 Sep 2004 19:05:16 -0500, Jim Grill [EMAIL PROTECTED] wrote:
   1) there is no need to fiddle with directory permissions to write images.
   2) if the content is sensitive you have the added security of the database
   password (and the fact that the database is ususally not directly
   accessible).
   3) a mysqldump gives a backup of all images along with other persistent
  data
  
   Other disadvantages follow:
   1) excessive load on the server for loading each image
   2) the load mentioned above causes a slow down in the script
   3) images usually need to be written to file before using GD for
   manipulation, inclusion in PDFs, etc.
  
  That's a very good list.
 
  I just wanted to pipe in on this one thing:
 
  3) images usually need to be written to file before using GD for
  manipulation, inclusion in PDFs, etc.
 
  There is actually a function for this: imagecreatefromstring()
 
  I'll don't want to touch the rest of this topic though. :-)
 
  Jim Grill
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 --
 
 Jasper Howard - Database Administration
 ApexEleven.com
 530 559 0107
 ---
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



RE: [PHP] Images in PHP and MySQL

2004-09-30 Thread Jay Blanchard
[snip]
HEre is a question that I have been wondering about:

   - Does the image file use more space in the db or as a file itself
(Do Not count the extra data that one would store in the db along with
the image... ie. ID number)
[/snip]

While better asked on a SQL list, I'll give you an answer from
http://dev.mysql.com/doc/mysql/en/Storage_requirements.html

VARCHAR and the BLOB and TEXT types are variable-length types. For
each, the storage requirements depend on the actual length of column
values (represented by L in the preceding table), rather than on the
type's maximum possible size. For example, a VARCHAR(10) column can hold
a string with a maximum length of 10 characters. The actual storage
required is the length of the string (L), plus 1 byte to record the
length of the string. For the string 'abcd', L is 4 and the storage
requirement is 5 bytes. 

The BLOB and TEXT types require 1, 2, 3, or 4 bytes to record the length
of the column value, depending on the maximum possible length of the
type.

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



Re: [PHP] Images in PHP and MySQL

2004-09-30 Thread Jasper Howard
I'm not any kind of expert on this, but you just read the file byte
for byte, dont you? So it should be the same amount of data.


On Thu, 30 Sep 2004 15:51:28 -0400, GH [EMAIL PROTECTED] wrote:
 HEre is a question that I have been wondering about:
 
   - Does the image file use more space in the db or as a file itself
 (Do Not count the extra data that one would store in the db along with
 the image... ie. ID number)
 
 Thanks
 
 
 
 
 On Thu, 30 Sep 2004 09:55:30 -0700, Jasper Howard [EMAIL PROTECTED] wrote:
  If you're uploading a file then you can make a script that reads the
  temp file into the database (otherwise you need to muck around with
  image functions and I'm not the one to ask about that), something
  like:
 
  $image = mysql_escape_string(fread(fopen($_FILES['file']['tmp_name'],
  r), filesize($_FILES['file']['tmp_name'])));
 
  Then you just put $image in the db under a BLOG field type. This is
  what I did when I needed to save some images to a db and it seemed to
  work fine. Make sure you save the file type to the database so you can
  display the image properly. When you are ready to display an image,
  just create the html for an image and set the source to a php script
  that will output the image:
 
  img src=scripts/display_image.php?id=1
 
  And in the display_image.php script do something like this:
 
  ?
  ...DB QUERY...
 
  $type = $row['file_type'];
  $dfile = $row['file_data'];
  header(Content-Type: $type);
  header(Content-Disposition: filename=.basename($dfile).;);
  header(Content-Length: .filesize($dfile));
  readfile($dfile);
  exit;
  ?
 
  That code was modified a bit from its origional function (forcing
  download of the file) but I think it should just work, but there's
  always the chance I messed it up somehow.
 
  hope that works for someone,
  -Jasper Howard
 
 
 
 
  On Mon, 27 Sep 2004 19:05:16 -0500, Jim Grill [EMAIL PROTECTED] wrote:
1) there is no need to fiddle with directory permissions to write images.
2) if the content is sensitive you have the added security of the database
password (and the fact that the database is ususally not directly
accessible).
3) a mysqldump gives a backup of all images along with other persistent
   data
   
Other disadvantages follow:
1) excessive load on the server for loading each image
2) the load mentioned above causes a slow down in the script
3) images usually need to be written to file before using GD for
manipulation, inclusion in PDFs, etc.
   
   That's a very good list.
  
   I just wanted to pipe in on this one thing:
  
   3) images usually need to be written to file before using GD for
   manipulation, inclusion in PDFs, etc.
  
   There is actually a function for this: imagecreatefromstring()
  
   I'll don't want to touch the rest of this topic though. :-)
  
   Jim Grill
  
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
 
  --
  
  Jasper Howard - Database Administration
  ApexEleven.com
  530 559 0107
  ---
 
 
  
  --
 
 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 



-- 

Jasper Howard - Database Administration
ApexEleven.com
530 559 0107
---

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



RE: [PHP] Images in PHP and MySQL

2004-09-30 Thread Ed Lazor
Images take up more space when stored in the db, because you're storing raw
binary data.  Gif and jpeg are compression methods that convert binary data
into something smaller that can be stored in a file.

The recent tests I did took 270megs of images and stored them into 180megs
of jpg files.

-Ed



 -Original Message-
 HEre is a question that I have been wondering about:
 
- Does the image file use more space in the db or as a file itself
 (Do Not count the extra data that one would store in the db along with
 the image... ie. ID number)

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



Re: [PHP] Images in PHP and MySQL

2004-09-30 Thread Jason Wong
On Friday 01 October 2004 05:52, Ed Lazor wrote:
 Images take up more space when stored in the db, because you're storing raw
 binary data.  Gif and jpeg are compression methods that convert binary data
 into something smaller that can be stored in a file.

??

If you store a jpeg file into a database blob, the database doesn't magically 
decompress the jpeg file. It will just treat the jpeg file as any other 
binary file and store it as-is (plus any overhead).

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
I went into a general store, and they wouldn't sell me anything specific.
-- Steven Wright
*/

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



[PHP] Images in PHP and MySQL

2004-09-27 Thread GH
I was wondering how to get images into and out of a Mysql database
with in php... I do not have anything in my book... but was told it
was possible.

I have PHP 4.3.4 and mysql 4.0.18

Thanks

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



Re: [PHP] Images in PHP and MySQL

2004-09-27 Thread Daniel Watrous
I don't.  I have used it on several projects.  One caveat I would offer is 
that this is much slower than one might think.  Three possible advantages 
come from using this approach:

1) there is no need to fiddle with directory permissions to write images.
2) if the content is sensitive you have the added security of the database 
password (and the fact that the database is ususally not directly 
accessible).
3) a mysqldump gives a backup of all images along with other persistent data

Other disadvantages follow:
1) excessive load on the server for loading each image
2) the load mentioned above causes a slow down in the script
3) images usually need to be written to file before using GD for 
manipulation, inclusion in PDFs, etc.

I have found that when I decide to store image data in the database I will 
usually also store a copy of the image on the server (as a file) also, 
primarily for performance reasons.

- Original Message - 
From: GH [EMAIL PROTECTED]
To: Daniel Watrous [EMAIL PROTECTED]
Cc: GH [EMAIL PROTECTED]
Sent: Monday, September 27, 2004 4:31 PM
Subject: Re: [PHP] Images in PHP and MySQL


Do you know of a good tutorial on this topic.
On Mon, 27 Sep 2004 16:25:15 -0600, Daniel Watrous
[EMAIL PROTECTED] wrote:
consider using a blob field type.  you will need to prepare your data on 
the
way in, but not on the way out of DB:

$content = addslashes(fread(fopen($_FILES[imgb_sizedesc][tmp_name],
r), filesize($_FILES[imgb_sizedesc][tmp_name])));
then instert $content into your DB using insert!

- Original Message -
From: GH [EMAIL PROTECTED]
To: php-general [EMAIL PROTECTED]
Sent: Monday, September 27, 2004 4:19 PM
Subject: [PHP] Images in PHP and MySQL
I was wondering how to get images into and out of a Mysql database
 with in php... I do not have anything in my book... but was told it
 was possible.

 I have PHP 4.3.4 and mysql 4.0.18

 Thanks

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



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


RE: [PHP] Images in PHP and MySQL

2004-09-27 Thread Graham Cossey
I'm no certified expert, but preference would be storing a URL to an image
in the database rather than the image itself.

If however you do want to store them in the db try using a blob column type.

This article is PHP3 but shows the basics:
http://www.phpbuilder.com/columns/florian19991014.php3

HTH

Graham

-Original Message-
From: GH [mailto:[EMAIL PROTECTED]
Sent: 27 September 2004 23:19
To: php-general
Subject: [PHP] Images in PHP and MySQL


I was wondering how to get images into and out of a Mysql database
with in php... I do not have anything in my book... but was told it
was possible.

I have PHP 4.3.4 and mysql 4.0.18

Thanks

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

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



Re: [PHP] Images in PHP and MySQL

2004-09-27 Thread GH
I hope that there are others out there that could weigh in on this topic please 

The more information and perspective I have the better as it would
help me build the most informed decision as posible.


On Mon, 27 Sep 2004 23:49:33 +0100, Graham Cossey
[EMAIL PROTECTED] wrote:
 I'm no certified expert, but preference would be storing a URL to an image
 in the database rather than the image itself.
 
 If however you do want to store them in the db try using a blob column type.
 
 This article is PHP3 but shows the basics:
 http://www.phpbuilder.com/columns/florian19991014.php3
 
 HTH
 
 Graham
 
 -Original Message-
 From: GH [mailto:[EMAIL PROTECTED]
 Sent: 27 September 2004 23:19
 To: php-general
 Subject: [PHP] Images in PHP and MySQL
 
 I was wondering how to get images into and out of a Mysql database
 with in php... I do not have anything in my book... but was told it
 was possible.
 
 I have PHP 4.3.4 and mysql 4.0.18
 
 Thanks
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP] Images in PHP and MySQL

2004-09-27 Thread Jim Grill
 1) there is no need to fiddle with directory permissions to write images.
 2) if the content is sensitive you have the added security of the database
 password (and the fact that the database is ususally not directly
 accessible).
 3) a mysqldump gives a backup of all images along with other persistent
data

 Other disadvantages follow:
 1) excessive load on the server for loading each image
 2) the load mentioned above causes a slow down in the script
 3) images usually need to be written to file before using GD for
 manipulation, inclusion in PDFs, etc.

That's a very good list.

I just wanted to pipe in on this one thing:

3) images usually need to be written to file before using GD for
manipulation, inclusion in PDFs, etc.

There is actually a function for this: imagecreatefromstring()

I'll don't want to touch the rest of this topic though. :-)

Jim Grill

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



[PHP] images outside of document root

2004-07-06 Thread Dennis Gearon
I want to keep an entire library OUTSIDE of the document root. The library includes 
some imgages. How can I have the browser include the imageges?
I've hard of BASE64'ing the images into the header and decoding them using javascript. Is this the best way? Where is code to do that? 

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


Re: [PHP] images outside of document root

2004-07-06 Thread Curt Zirzow
* Thus wrote Dennis Gearon:
 I want to keep an entire library OUTSIDE of the document root. The library 
 includes some imgages. How can I have the browser include the imageges?
 
 I've hard of BASE64'ing the images into the header and decoding them using 
 javascript. Is this the best way? Where is code to do that? 

no, its probably the worst way. 

To have the browser reference images outside the document root
you'll have to create a php wrapper function that decides on what
to do:

img src=/showimage.php?file=foobar.jpg

showimage.php:
?php

$file = $_GET['file'];

// authentication if needed...
// check for valid file, etc..

header('Content-Type: image/jpeg'); // send right content type
readfile($path_outside_docroot . $file);


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

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



Re: [PHP] images outside of document root

2004-07-06 Thread Dennis Gearon
I may do that, but the 'showimage.php' file then has to be in the 
document root, and can be attacked a LOT.

I have found ways to do inline images, without javascript, I believe.
Curt Zirzow [EMAIL PROTECTED] wrote:
* Thus wrote Dennis Gearon:
I want to keep an entire library OUTSIDE of the document root. The library 
includes some imgages. How can I have the browser include the imageges?

I've hard of BASE64'ing the images into the header and decoding them using 
javascript. Is this the best way? Where is code to do that? 
 

no, its probably the worst way. 

To have the browser reference images outside the document root
you'll have to create a php wrapper function that decides on what
to do:
img src=/showimage.php?file=foobar.jpg
showimage.php:
?php
$file = $_GET['file'];
// authentication if needed...
// check for valid file, etc..
header('Content-Type: image/jpeg'); // send right content type
readfile($path_outside_docroot . $file);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] images outside of document root

2004-07-06 Thread Keith Greene
I use a system like that described below, however I added some checks to 
thwart attack.
first, the image serving script checks to make sure the user has a session 
id. This prevents people just loading the script to get the images, and 
also deters hot linking.
second, I have a script that runs once an hour and generates a random word 
and saves it to a text file. That file is read by the page that calls the 
image serving script, and the word contained within is md5 hashed, then 
passed to the image serving script like this:
img src='imgserv.php?i=joe.jpgh=fc5e038d38a57032085441e7fe7010b0' border=0

the image serving script then loads the same text file, hashes the word 
within and compares the hashes. If they don't match, the link is over an 
hour old and the image isn't served.

I know there are circumstances where an image can be hotlinked and 
viewable, but the hotlink only works for an hour, and only for people who 
have actually visited my site during their current browser session, and 
this I can live with.

Keith
At 01:20 PM 7/6/2004, Dennis Gearon wrote:
I may do that, but the 'showimage.php' file then has to be in the document 
root, and can be attacked a LOT.

I have found ways to do inline images, without javascript, I believe.
Curt Zirzow [EMAIL PROTECTED] wrote:
* Thus wrote Dennis Gearon:
I want to keep an entire library OUTSIDE of the document root. The 
library includes some imgages. How can I have the browser include the imageges?
I've hard of BASE64'ing the images into the header and decoding them 
using javascript. Is this the best way? Where is code to do that?

no, its probably the worst way.
To have the browser reference images outside the document root
you'll have to create a php wrapper function that decides on what
to do:
img src=/showimage.php?file=foobar.jpg
showimage.php:
?php
$file = $_GET['file'];
// authentication if needed...
// check for valid file, etc..
header('Content-Type: image/jpeg'); // send right content type
readfile($path_outside_docroot . $file);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Images PHP

2004-04-19 Thread Tim Thorburn
Hi,

I've created a small program that allows users to upload an image, and then 
resize that image one or more times depending on the desired outcome (once 
for web documents, twice for photo galleries, etc).  Anyways, it seems that 
a large number of my clients are using older digital cameras to show case 
their businesses (most often resorts).  This usually means taking pictures 
in poor lighting conditions which leaves the images either so black you 
can't see anything or completely washed out.  I've seen a few functions on 
php.net that speak of changing color options, but so far these seem to be 
simple make this purple square red now types.  Is there something built 
into PHP, or a 3rd party function that I'm not aware of, that would do 
simple color correction on uploaded files?  I'm looking for a very quick 
and cheap auto levels like function found within Photoshop.

Any idea if this is even possible?

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


Re: [PHP] Images PHP

2004-04-19 Thread Andy B
dont know that much about images at the minute but phpclasses.org has tons
of image classes that might help...


- Original Message - 
From: Tim Thorburn [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, April 19, 2004 7:12 PM
Subject: [PHP] Images  PHP


 Hi,

 I've created a small program that allows users to upload an image, and
then
 resize that image one or more times depending on the desired outcome (once
 for web documents, twice for photo galleries, etc).  Anyways, it seems
that
 a large number of my clients are using older digital cameras to show case
 their businesses (most often resorts).  This usually means taking pictures
 in poor lighting conditions which leaves the images either so black you
 can't see anything or completely washed out.  I've seen a few functions on
 php.net that speak of changing color options, but so far these seem to be
 simple make this purple square red now types.  Is there something built
 into PHP, or a 3rd party function that I'm not aware of, that would do
 simple color correction on uploaded files?  I'm looking for a very quick
 and cheap auto levels like function found within Photoshop.

 Any idea if this is even possible?

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



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



[PHP] images

2004-03-16 Thread Maxi Yedid
hello

I'm using the following function from the php manual (user's posts) and get
the following error.

What I do is upload a file from the user and save it in the server; that's
working fine; what I want is to save a copy of the file in thumbnail size.


-
function resampimagejpg($forcedwidth, $forcedheight, $sourcefile, $destfile,$imgcomp)
   {
   $g_imgcomp=100-$imgcomp;
   $g_srcfile=$sourcefile;
   $g_dstfile=$destfile;
   $g_fw=$forcedwidth;
   $g_fh=$forcedheight;

   if(file_exists($g_srcfile))
   {
   $g_is=getimagesize($g_srcfile);
   if(($g_is[0]-$g_fw)=($g_is[1]-$g_fh))
   {
   $g_iw=$g_fw;
   $g_ih=($g_fw/$g_is[0])*$g_is[1];
   }
   else
   {
   $g_ih=$g_fh;
   $g_iw=($g_ih/$g_is[1])*$g_is[0];
   }
   $img_src=imagecreatefromjpeg($g_srcfile);
   $img_dst=imagecreate($g_iw,$g_ih);

   imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $g_iw, $g_ih,$g_is[0], 
$g_is[1]);
   imagejpeg($img_dst, $g_dstfile, $g_imgcomp);
   imagedestroy($img_dst);
   return true;
   }
   else
   return false;
   }
--
** This is where I call the function:

  $archivo = $forma['imagen']['tmp_name'];
  echo(bFile Uploaded Information:/b br . $archivo . br);

  if(is_uploaded_file($archivo)) {
   $directo = /home/public_html/img_products/;
   $archivito = $directo . $forma['imagen']['name'];

   $archivote = /home/public_html/img_small_products/ .
$forma['imagen']['name'];  //

   echo br . $archivito . hr;
move_uploaded_file($forma['imagen']['tmp_name'],$archivito) ;

   resampimagejpg(100, 100, $archivito, $archivote, 0);
= Here I call the function

--

This is the error I get:

Warning: imagejpeg(): Unable to open '/home/public_html/img_small_products/A2_6.jpg' 
for writing in /home/public_html/admin/products.php on line 286

any idea? Thanks!

max



Re: [PHP] Images in MySQL vs directory/file?

2003-12-11 Thread Derrick Fogle
Thanks for the feedback. Just to clear up a couple questions regarding 
my particular needs...

1. server has *plenty* of capacity
2. traffic is *very* low; max load would be 20 visitors looking at 4 
images apiece over a 4-hour period
3. images will only be retrieved once or twice by one or two different 
browsers, over the period of a week (then they will be deleted).
4. I *don't* need, or want, the files to be backed up

It seems to me that I can get more/better control over the tracking and 
use of the images if I store them in the DB. On the other hand, the 
'simple' solution to the open directory problem is to put it outside 
the www root and fread the file from there to spit out to the browsers.

I'm going to go with the database option for now, despite the fact that 
it will include the stuff in backups if I do, for a couple of selfish 
reasons: I've already got the code written and working, while moving 
the directory around and having to fread and then puke out the data 
will be more work, and I *do* have more control/access over database 
records than I do server directories.

Thanks for everyone's help!

-Derrick

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


[PHP] Images in MySQL vs directory/file?

2003-12-10 Thread Derrick Fogle
Slightly OT, but I'm hoping for a few opinions about handling JPG/MOV 
files with PHP/MySQL.

I've read that, given the choice, you should never store images in a 
database because it makes the database dog slow. But I've got some 
parameters and issues that might make a difference:

1. The only way I can store the files in a directory on the server is 
to make that directory wide open as in chmod 777. I don't have quite 
enough control of the server to make that a better situation.

2. The images will only be stored temporarily - I'm looking at a 
maximum of 100Mb worth of JPG and MOV files (up to 80 1Mb JPG, up to 10 
2Mb MOV files) being stored at any one time.

So, am I going to run into performance issues with that amount of blob 
data in the database? The probability of a hack on my images directory 
is extremely low, but it *does* exist of course.

Comments?

Thanks,

-Derrick

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


Re: [PHP] Images in MySQL vs directory/file?

2003-12-10 Thread Richard Davey
Hello Derrick,

Wednesday, December 10, 2003, 3:56:32 PM, you wrote:

DF 1. The only way I can store the files in a directory on the server is
DF to make that directory wide open as in chmod 777. I don't have quite
DF enough control of the server to make that a better situation.

Why is this? More to the point.. is there somewhere else you could
store them (i.e. a directory outside of the web root from which you
could fread the files).

DF 2. The images will only be stored temporarily - I'm looking at a 
DF maximum of 100Mb worth of JPG and MOV files (up to 80 1Mb JPG, up to 10
DF 2Mb MOV files) being stored at any one time.

DF So, am I going to run into performance issues with that amount of blob
DF data in the database? The probability of a hack on my images directory
DF is extremely low, but it *does* exist of course.

Performance is a very subjective term - are you putting this site on
an overloaded shared box that might frown at such hammering of its
MySQL server. Or are you hosting on a dedicated machine that has
enough processing power to start the next cold war?

You will of course hit performance issues, but the scale of them
depends on factors outside of PHP/MySQL. I personally would
investigate an alternative location to store them.

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



Re: [PHP] Images in MySQL vs directory/file?

2003-12-10 Thread Adam i Agnieszka Gasiorowski FNORD
Derrick Fogle wrote:
 
 I've read that, given the choice, you should never store images in a
 database because it makes the database dog slow. But I've got some
 parameters and issues that might make a difference:

We (at hyperreal.info) are storing all the
 images attached to articles in the database and
 all the structural images (belonging to design)
 in files on filesystem (in CVS). There are no 
 problems and backups are much easier...The server
 runs on LAMP.

-- 
Seks, seksi, seksolatki... news:pl.soc.seks.moderowana
http://hyperreal.info  { iWanToDie }   WiNoNa)   (
http://szatanowskie-ladacznice.0-700.pl  foReVeR(  *  )
Poznaj jej zwiewne ksztaty... http://www.opera.com 007

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



Re: [PHP] Images in MySQL vs directory/file?

2003-12-10 Thread Galen
I tend to disagree. Images in the database, providing they actually 
associate with other bits of info, are great. I usually keep images in 
a separate table than the data, but it's really easy to keep track of 
everything. No file permissions, backup is as easy as standard SQL 
backups, etc. I my experience, it's a LOT easier to keep track of stuff 
in the database than the filesystem, especially when it comes to moving 
from box to box. There may also be some security advantages, too, as 
the data is not actually stored in the filesystem and couldn't possibly 
be executed or otherwise accessed by someone without database access 
privileges.

As far as it being slow, well, not terribly as long as your files don't 
balloon too large, especially considering all the stuff you might be 
doing with the disk. If you store images that are played with a lot on 
the disk, it'll likely be slower than MySQL due to MySQL having better 
caching. (I have actually shown this on some of my projects that work 
with a lot of images that are worked with quite a bit).

If your site is going to be high volume traffic, implement some sort of 
caching routine for your images. You'll get the convenience of database 
and the performance boost of caching, and as always, if the cache 
fails, just hit the database for the information.

For your needs, give it a try. I doubt you'll have performance 
problems, and you can always switch back to the filesystem if you do 
have troubles.

-Galen

If you are going to be passing images

On Dec 10, 2003, at 10:32 AM, Adam i Agnieszka Gasiorowski FNORD wrote:

Derrick Fogle wrote:

I've read that, given the choice, you should never store images in a
database because it makes the database dog slow. But I've got some
parameters and issues that might make a difference:
We (at hyperreal.info) are storing all the
 images attached to articles in the database and
 all the structural images (belonging to design)
 in files on filesystem (in CVS). There are no
 problems and backups are much easier...The server
 runs on LAMP.
--
Seks, seksi, seksolatki... news:pl.soc.seks.moderowana
http://hyperreal.info  { iWanToDie }   WiNoNa)   (
http://szatanowskie-ladacznice.0-700.pl  foReVeR(  *  )
Poznaj jej zwiewne ksztaty... http://www.opera.com 007
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


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


Re: [PHP] Images in MySQL vs directory/file?

2003-12-10 Thread Justin Patrin
Galen wrote:

I tend to disagree. Images in the database, providing they actually 
associate with other bits of info, are great. I usually keep images in a 
separate table than the data, but it's really easy to keep track of 
everything. No file permissions, backup is as easy as standard SQL 
backups, etc. I my experience, it's a LOT easier to keep track of stuff 
in the database than the filesystem, especially when it comes to moving 
from box to box. There may also be some security advantages, too, as the 
data is not actually stored in the filesystem and couldn't possibly be 
executed or otherwise accessed by someone without database access 
privileges.

As far as it being slow, well, not terribly as long as your files don't 
balloon too large, especially considering all the stuff you might be 
doing with the disk. If you store images that are played with a lot on 
the disk, it'll likely be slower than MySQL due to MySQL having better 
caching. (I have actually shown this on some of my projects that work 
with a lot of images that are worked with quite a bit).

If your site is going to be high volume traffic, implement some sort of 
caching routine for your images. You'll get the convenience of database 
and the performance boost of caching, and as always, if the cache fails, 
just hit the database for the information.

For your needs, give it a try. I doubt you'll have performance problems, 
and you can always switch back to the filesystem if you do have troubles.

-Galen

If you are going to be passing images

On Dec 10, 2003, at 10:32 AM, Adam i Agnieszka Gasiorowski FNORD wrote:

Derrick Fogle wrote:

I've read that, given the choice, you should never store images in a
database because it makes the database dog slow. But I've got some
parameters and issues that might make a difference:


We (at hyperreal.info) are storing all the
 images attached to articles in the database and
 all the structural images (belonging to design)
 in files on filesystem (in CVS). There are no
 problems and backups are much easier...The server
 runs on LAMP.
--
Seks, seksi, seksolatki... news:pl.soc.seks.moderowana
http://hyperreal.info  { iWanToDie }   WiNoNa)   (
http://szatanowskie-ladacznice.0-700.pl  foReVeR(  *  )
Poznaj jej zwiewne ksztaty... http://www.opera.com 007
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



I agree, storing images in the database can be a big help.

For caching, you may want to try PEAR's Cache package.

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


Re: [PHP] Images in MySQL vs directory/file?

2003-12-10 Thread Gerard Samuel
On Wednesday 10 December 2003 02:43 pm, Galen wrote:
 If you store images that are played with a lot on
 the disk, it'll likely be slower than MySQL due to MySQL having better
 caching.

I disagree.
Depending on your setup, when a file based image is downloaded to 
a user's computer, its cached there.
No need to fetch it again, till it expires.
I don't think thats possible via images from a database, but
I may be wrong.  Feel free to correct me...

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



RE: [PHP] Images in MySQL vs directory/file?

2003-12-10 Thread Brian . Goralczyk
Well, it seems to me that the confusion comes from the fact that we are
comparing apples and oranges. 

The first example is talking about the performance assuming you have 100's
of people requesting the same picture, where as the second example is
talking about the performance assuming you have the same person
re-downloading the same picture.

But I would also like to question the extra layer.  Not that MySQL doesn't
have better caching, that is possible,  but it adds and extra layer to the
process because MySQL still stores the data on the drive.  Also, does the
web server cache images?  If so, then we are ahead of the game even more.  

Just my ramblings on the subject and since I am not an expert at this whole
PHP thing please correct me.

Brian Goralczyk
Verizon Wireless

-Original Message-
From: Gerard Samuel [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 10, 2003 3:35 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Images in MySQL vs directory/file?


On Wednesday 10 December 2003 02:43 pm, Galen wrote:
 If you store images that are played with a lot on
 the disk, it'll likely be slower than MySQL due to MySQL having better
 caching.

I disagree.
Depending on your setup, when a file based image is downloaded to 
a user's computer, its cached there.
No need to fetch it again, till it expires.
I don't think thats possible via images from a database, but
I may be wrong.  Feel free to correct me...

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

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



Re: [PHP] Images in MySQL vs directory/file?

2003-12-10 Thread Galen
On Dec 10, 2003, at 12:47 PM, [EMAIL PROTECTED] wrote:

Well, it seems to me that the confusion comes from the fact that we are
comparing apples and oranges.
I agree. Images in a database mean totally different things to 
different usage profiles.

But I would also like to question the extra layer.  Not that MySQL 
doesn't
have better caching, that is possible,  but it adds and extra layer to 
the
process because MySQL still stores the data on the drive.  Also, does 
the
web server cache images?  If so, then we are ahead of the game even 
more.
I think the extra layer is a mixed blessing. Yes, it can slow things 
down. But at the same time, it can use caching to make up for the 
slowdown in many cases, especially when writing. What the extra layer 
provides is structure and ease of use and (depending on your setup) 
security. For many applications, the benefits outweigh the costs. There 
are certainly many applications (high traffic sites come to mind) where 
file-based is the way to go, or at least an extensive caching system 
would be required.

From: Gerard Samuel [mailto:[EMAIL PROTECTED]
I disagree.
Depending on your setup, when a file based image is downloaded to
a user's computer, its cached there.
No need to fetch it again, till it expires.
I don't think thats possible via images from a database, but
I may be wrong.  Feel free to correct me...
Actually, the real problem these days with browsers is that you can't 
get them to STOP caching! At least in my experience, properly used 
headers don't even stop caching pages quite 100% of the time. If you 
retrieve an image from the database via url-encoded stuff (i.e. 
mysite.com/image.php?id=234) the browser will probably cache it no 
problem unless you send no-cache headers.

This is obviously a bit of a hot issue. I think that anybody seriously 
interested in this should try it with his or her setup and see how it 
works. I bet that for most people, it won't be a big deal at all. But 
for a few others, if implemented across their whole site, it could 
cause lots of CPU usage problems.

Give it a try. You might like it.

-Galen

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


Re: [PHP] Images in MySQL vs directory/file?

2003-12-10 Thread Justin Patrin
Gerard Samuel wrote:

On Wednesday 10 December 2003 02:43 pm, Galen wrote:

If you store images that are played with a lot on
the disk, it'll likely be slower than MySQL due to MySQL having better
caching.


I disagree.
Depending on your setup, when a file based image is downloaded to 
a user's computer, its cached there.
No need to fetch it again, till it expires.
I don't think thats possible via images from a database, but
I may be wrong.  Feel free to correct me...
Images are cached client side just as html pages are. Scripts are no 
exception. A script which outputs an image will have the same URI over 
and over, so it will be cached. If the browser isn't cacheing as you 
want, you can always send a header telling the browser to cache it.

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


[PHP] Images On-Fly

2003-12-03 Thread Dejan Dujak
Hallo People,



I have one problem with creating images on-fly.

Therefore I created 2 files:

1. resize_image.php with the following

?php

if (!$max_width)

$max_width = 150;

if (!$max_height)

$max_height = 100;

$size = GetImageSize($image);

$width = $size[0];

$height = $size[1];

$x_ratio = $max_width / $width;

$y_ratio = $max_height / $height;

if ( ($width = $max_width)  ($height = $max_height) ) {

$tn_width = $width;

$tn_height = $height;

}

else if (($x_ratio * $height)  $max_height) {

$tn_height = ceil($x_ratio * $height);

$tn_width = $max_width;

}

else {

$tn_width = ceil($y_ratio * $width);

$tn_height = $max_height;

}

$src = ImageCreateFromJpeg($image);

$dst = ImageCreate($tn_width,$tn_height);

ImageCopyResized($dst, $src, 0, 0, 0, 0,

$tn_width,$tn_height,$width,$height);

header(Content-type: image/jpeg);

ImageJpeg($dst, null, -1);

ImageDestroy($src);

ImageDestroy($dst);

?

AND

2. filex.php .In that file i read from database where the image is stored en

then i show small images(thumbnails).

thet part of the code is :

?php do { ?

tr

td width=156 height=32 valign=top?php echo

$row_rsSubGroup['name']; ?/td

td colspan=2 valign=top?php

$fotolink=../dbtest/.$row_rsSubGroup['image_1']);

echo IMG

SRC=\resize_image.php?image=$fotolink\;

?

/td

/tr

?php } while ($row_rsSubGroup = mysql_fetch_assoc($rsSubGroup)); ?





This doesn't WORK. Please HELP.

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



Re: [PHP] Images On-Fly

2003-12-03 Thread Jason Wong
On Wednesday 03 December 2003 17:41, Dejan Dujak wrote:

[snip]

 This doesn't WORK. Please HELP.

HOW DOESN'T it work?

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Your reasoning powers are good, and you are a fairly good planner.
*/

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



[PHP] images and charset

2003-11-19 Thread Egil Berntsen
I put some text from my mysql-db into images(jpeg and png) that I build on
the fly. When I do this I have som problem with norwegian spesial charakter,
they dont show properly in the images. If I put the same text directly to
the browser window this will show correctly.
What do I need to do to get this right?

thanks
egil

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



RE: [PHP] Images being uploaded in ASCII format

2003-10-23 Thread Pablo Gosse
Hi Tom.

 make sure you have ENCTYPE=multipart/form-data in the form tag

Thanks for the tip, but that's not the problem.  My code is below, and
as you can see there is nothing in the code that would be causing this.
It has to be something in the server, and while there have been a few
posts to these lists about this problem, never a resolution for the
problem.

Here's the code:

?php
function handleupload()
{
if (is_uploaded_file($_FILES['userfile']['tmp_name']))
{
$realname = $_FILES['userfile']['name'];
if(copy($_FILES['userfile']['tmp_name'],
'/path/to/file/'.$realname))
{
echo 'br /'.$realname.' uploaded/font';
}
else
{
echo 'br /'.$realname.'could not be
uploaded/font';
}
}
else
{
echo 'br /Possible file upload attack: filename
'.$_FILES['userfile']['name'].'.';
}
}
?
html
head
titleFile Upload/title
/head
body
?php
if (isset($_POST['method'])  $_POST['method'] == 'upload')
handleupload();
?
form ENCTYPE=multipart/form-data method=POST action=?php echo
$_SERVER['PHP_SELF']; ?
input type=hidden name=method value=upload
File:input type=file name=userfile size=35
input type=submit value=upload name=submit
/form
/body
/html

This is very standard code, yet the images are uploaded in ascii format.

Does anyone have any idea why this is happening?  How can I for the http
uploads to auto-detect?  I've looked through the entire php.ini and
httpd.conf files and I can't seem to find anything, and as I mentioned
above none of the previous posts on this topic have been resolved.

Anyone?

Thanks much in advance,
Pablo

Thursday, October 23, 2003, 4:05:13 AM, you wrote:
PG Hi all.  I'd like to take a brief sentence to introduce myself
first.
PG My name is Pablo Gosse, and I've just recently joined the
php-general
PG list.  I've been using PHP since early 2000, and work as webmaster
PG at the University of Northern British Columbia.

PG I'm running into a problem with file uploads being handled in ascii
PG rather than binary format.

PG I've been writing a CMS for the past few months and the wysiwyg
editor
PG we're integrating has a very nice image manager built in
PG (www.devedit.com).  However, the uploads are being transferred in
ascii
PG format instead of binary (or auto-detect) which is mangling all the
PG images.

PG I've done a lot of research into this but can't seem to pin down the
PG problem.  I've looked through both my php.ini and httpd.conf and
can't
PG seem to find anything there that would remedy this problem.

PG Does anyone have any advice as to where I should be looking to fix
this
PG problem?

PG Thanks much in advance.

PG Cheers,
PG Pablo

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



Re: [PHP] Images being uploaded in ASCII format

2003-10-23 Thread Raditha Dissanayake
Hi Pablo,

Could you explain what exactly you mean by transferred in ASCII mode? do 
you find that cr/lf combinations are translated (there by corrupting 
your image) or some other corruption takes place?

Have you opened the files with a hex editor to see the contents? I am 
sorry if you have mentioned these before, i don't have the older 
messages in this thread.



Pablo Gosse wrote:

Hi Tom.

 

make sure you have ENCTYPE=multipart/form-data in the form tag
   

Thanks for the tip, but that's not the problem.  My code is below, and
as you can see there is nothing in the code that would be causing this.
It has to be something in the server, and while there have been a few
posts to these lists about this problem, never a resolution for the
problem.
Here's the code:

?php
function handleupload()
{
if (is_uploaded_file($_FILES['userfile']['tmp_name']))
{
$realname = $_FILES['userfile']['name'];
if(copy($_FILES['userfile']['tmp_name'],
'/path/to/file/'.$realname))
{
echo 'br /'.$realname.' uploaded/font';
}
else
{
echo 'br /'.$realname.'could not be
uploaded/font';
}
}
else
{
echo 'br /Possible file upload attack: filename
'.$_FILES['userfile']['name'].'.';
}
}
?
html
head
titleFile Upload/title
/head
body
?php
if (isset($_POST['method'])  $_POST['method'] == 'upload')
handleupload();
?
form ENCTYPE=multipart/form-data method=POST action=?php echo
$_SERVER['PHP_SELF']; ?
input type=hidden name=method value=upload
File:input type=file name=userfile size=35
input type=submit value=upload name=submit
/form
/body
/html
This is very standard code, yet the images are uploaded in ascii format.

Does anyone have any idea why this is happening?  How can I for the http
uploads to auto-detect?  I've looked through the entire php.ini and
httpd.conf files and I can't seem to find anything, and as I mentioned
above none of the previous posts on this topic have been resolved.
Anyone?

Thanks much in advance,
Pablo
Thursday, October 23, 2003, 4:05:13 AM, you wrote:
PG Hi all.  I'd like to take a brief sentence to introduce myself
first.
PG My name is Pablo Gosse, and I've just recently joined the
php-general
PG list.  I've been using PHP since early 2000, and work as webmaster
PG at the University of Northern British Columbia.
PG I'm running into a problem with file uploads being handled in ascii
PG rather than binary format.
PG I've been writing a CMS for the past few months and the wysiwyg
editor
PG we're integrating has a very nice image manager built in
PG (www.devedit.com).  However, the uploads are being transferred in
ascii
PG format instead of binary (or auto-detect) which is mangling all the
PG images.
PG I've done a lot of research into this but can't seem to pin down the
PG problem.  I've looked through both my php.ini and httpd.conf and
can't
PG seem to find anything there that would remedy this problem.
PG Does anyone have any advice as to where I should be looking to fix
this
PG problem?
PG Thanks much in advance.

PG Cheers,
PG Pablo
 



--
Raditha Dissanayake.

http://www.radinks.com/sftp/  |  http://www.raditha/megaupload/
Lean and mean Secure FTP applet with  |  Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB  |  with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Images being uploaded in ASCII format

2003-10-23 Thread Pablo Gosse
Hi Raditha.  Thanks very much for your reply.  I've not been having much
luck with this one.

This is how the images should appear:
http://web.unbc.ca/~gossep/sample_images/1.gif
http://web.unbc.ca/~gossep/sample_images/nav-02.jpg

And here is how they appear after being uploaded:
http://web.unbc.ca/~gossep/sample_images/1_uploaded.gif
http://web.unbc.ca/~gossep/sample_images/nav-02_uploaded.jpg

The results to me seem the same as if an image were FTPed in ascii mode
instead of binary mode (or auto-detect which would ultimately set the
mode to binary).

I just downloaded the XVI32 hex editor, but what should I be looking for
when I open the files and examine the contents?

Some other particulars to this situation:

I've tried uploading the same images through the demo site on the
company from which we purchased our editor (www.devedit.com) and they
upload fine, making me certain it's a system setting on my system
causing the problem.

My system is as follows:

Dell Precision 340 Workstation
RedHat 9.0
Apache 2.0
PHP 4.2.2

Thanks with your help, Raditha.  Greatly appreciated.

Cheers,
Pablo

-Original Message-
From: Raditha Dissanayake [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 23, 2003 10:19 AM
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Images being uploaded in ASCII format


Hi Pablo,

Could you explain what exactly you mean by transferred in ASCII mode? do

you find that cr/lf combinations are translated (there by corrupting 
your image) or some other corruption takes place?

Have you opened the files with a hex editor to see the contents? I am 
sorry if you have mentioned these before, i don't have the older 
messages in this thread.




Pablo Gosse wrote:

Hi Tom.

  

make sure you have ENCTYPE=multipart/form-data in the form tag



Thanks for the tip, but that's not the problem.  My code is below, and
as you can see there is nothing in the code that would be causing this.
It has to be something in the server, and while there have been a few
posts to these lists about this problem, never a resolution for the
problem.

Here's the code:

?php
function handleupload()
{
   if (is_uploaded_file($_FILES['userfile']['tmp_name']))
   {
   $realname = $_FILES['userfile']['name'];
   if(copy($_FILES['userfile']['tmp_name'],
'/path/to/file/'.$realname))
   {
   echo 'br /'.$realname.' uploaded/font';
   }
   else
   {
   echo 'br /'.$realname.'could not be
uploaded/font';
   }
   }
   else
   {
   echo 'br /Possible file upload attack: filename
'.$_FILES['userfile']['name'].'.';
   }
}
?
html
head
titleFile Upload/title
/head
body
?php
if (isset($_POST['method'])  $_POST['method'] == 'upload')
handleupload();
?
form ENCTYPE=multipart/form-data method=POST action=?php echo
$_SERVER['PHP_SELF']; ?
input type=hidden name=method value=upload
File:input type=file name=userfile size=35
input type=submit value=upload name=submit
/form
/body
/html

This is very standard code, yet the images are uploaded in ascii
format.

Does anyone have any idea why this is happening?  How can I for the
http
uploads to auto-detect?  I've looked through the entire php.ini and
httpd.conf files and I can't seem to find anything, and as I mentioned
above none of the previous posts on this topic have been resolved.

Anyone?

Thanks much in advance,
Pablo

Thursday, October 23, 2003, 4:05:13 AM, you wrote:
PG Hi all.  I'd like to take a brief sentence to introduce myself
first.
PG My name is Pablo Gosse, and I've just recently joined the
php-general
PG list.  I've been using PHP since early 2000, and work as webmaster
PG at the University of Northern British Columbia.

PG I'm running into a problem with file uploads being handled in ascii
PG rather than binary format.

PG I've been writing a CMS for the past few months and the wysiwyg
editor
PG we're integrating has a very nice image manager built in
PG (www.devedit.com).  However, the uploads are being transferred in
ascii
PG format instead of binary (or auto-detect) which is mangling all the
PG images.

PG I've done a lot of research into this but can't seem to pin down
the
PG problem.  I've looked through both my php.ini and httpd.conf and
can't
PG seem to find anything there that would remedy this problem.

PG Does anyone have any advice as to where I should be looking to fix
this
PG problem?

PG Thanks much in advance.

PG Cheers,
PG Pablo

  



-- 
Raditha Dissanayake.

http://www.radinks.com/sftp/  |  http://www.raditha/megaupload/
Lean and mean Secure FTP applet with  |  Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB  |  with progress bar.

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

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

Re: [PHP] Images being uploaded in ASCII format

2003-10-23 Thread Raditha Dissanayake
Hi Pablo

Pablo Gosse wrote:

Hi Raditha.  Thanks very much for your reply.  I've not been having much
luck with this one.
welcome

This is how the images should appear:
http://web.unbc.ca/~gossep/sample_images/1.gif
http://web.unbc.ca/~gossep/sample_images/nav-02.jpg
And here is how they appear after being uploaded:
http://web.unbc.ca/~gossep/sample_images/1_uploaded.gif
http://web.unbc.ca/~gossep/sample_images/nav-02_uploaded.jpg
1.gif and 1_uploaded.gif differ by much as 4Kb in length! and the first 
difference occurs at byte number 1276. (I used cmp)

The results to me seem the same as if an image were FTPed in ascii mode
instead of binary mode (or auto-detect which would ultimately set the
mode to binary).
Though the output might look like that it's misleading because you are 
using HTTP post.  Unfortunately PHP does not allow access to raw POST 
data, else this can be debugged by looking at that data. I will mail you 
(offlist) a small perl script that you can use to write out the POST to 
a temp file and may be help you get to the bottom of this.

I just downloaded the XVI32 hex editor, but what should I be looking for
when I open the files and examine the contents?
Khexedit might be installed by default.

all the best



--
Raditha Dissanayake.

http://www.radinks.com/sftp/  |  http://www.raditha/megaupload/
Lean and mean Secure FTP applet with  |  Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB  |  with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Images being uploaded in ASCII format

2003-10-23 Thread Ricardo C. Fernandez de C.
Something wrong is with your uploader program... look at this:

Content-Disposition: form-data; name=upload; filename=C:\Documents
and Settin
gs\gossep\Desktop\ewimages\1.gif

And if you look closer to the data in the file, you will see it has 2
GIF or something (GIF8 twice)... so yep, you have something really wrong
with your uploader.

El jue, 23-10-2003 a las 13:22, Pablo Gosse escribió:
 Hi Raditha.  Thanks very much for your reply.  I've not been having much
 luck with this one.
 
 This is how the images should appear:
 http://web.unbc.ca/~gossep/sample_images/1.gif
 http://web.unbc.ca/~gossep/sample_images/nav-02.jpg
 
 And here is how they appear after being uploaded:
 http://web.unbc.ca/~gossep/sample_images/1_uploaded.gif
 http://web.unbc.ca/~gossep/sample_images/nav-02_uploaded.jpg
 
 The results to me seem the same as if an image were FTPed in ascii mode
 instead of binary mode (or auto-detect which would ultimately set the
 mode to binary).
 
 I just downloaded the XVI32 hex editor, but what should I be looking for
 when I open the files and examine the contents?
 
 Some other particulars to this situation:
 
 I've tried uploading the same images through the demo site on the
 company from which we purchased our editor (www.devedit.com) and they
 upload fine, making me certain it's a system setting on my system
 causing the problem.
 
 My system is as follows:
 
 Dell Precision 340 Workstation
 RedHat 9.0
 Apache 2.0
 PHP 4.2.2
 
 Thanks with your help, Raditha.  Greatly appreciated.
 
 Cheers,
 Pablo
 
 -Original Message-
 From: Raditha Dissanayake [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, October 23, 2003 10:19 AM
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] Images being uploaded in ASCII format
 
 
 Hi Pablo,
 
 Could you explain what exactly you mean by transferred in ASCII mode? do
 
 you find that cr/lf combinations are translated (there by corrupting 
 your image) or some other corruption takes place?
 
 Have you opened the files with a hex editor to see the contents? I am 
 sorry if you have mentioned these before, i don't have the older 
 messages in this thread.
 
 
 
 
 Pablo Gosse wrote:
 
 Hi Tom.
 
   
 
 make sure you have ENCTYPE=multipart/form-data in the form tag
 
 
 
 Thanks for the tip, but that's not the problem.  My code is below, and
 as you can see there is nothing in the code that would be causing this.
 It has to be something in the server, and while there have been a few
 posts to these lists about this problem, never a resolution for the
 problem.
 
 Here's the code:
 
 ?php
 function handleupload()
 {
  if (is_uploaded_file($_FILES['userfile']['tmp_name']))
  {
  $realname = $_FILES['userfile']['name'];
  if(copy($_FILES['userfile']['tmp_name'],
 '/path/to/file/'.$realname))
  {
  echo 'br /'.$realname.' uploaded/font';
  }
  else
  {
  echo 'br /'.$realname.'could not be
 uploaded/font';
  }
  }
  else
  {
  echo 'br /Possible file upload attack: filename
 '.$_FILES['userfile']['name'].'.';
  }
 }
 ?
 html
 head
 titleFile Upload/title
 /head
 body
 ?php
 if (isset($_POST['method'])  $_POST['method'] == 'upload')
 handleupload();
 ?
 form ENCTYPE=multipart/form-data method=POST action=?php echo
 $_SERVER['PHP_SELF']; ?
 input type=hidden name=method value=upload
 File:input type=file name=userfile size=35
 input type=submit value=upload name=submit
 /form
 /body
 /html
 
 This is very standard code, yet the images are uploaded in ascii
 format.
 
 Does anyone have any idea why this is happening?  How can I for the
 http
 uploads to auto-detect?  I've looked through the entire php.ini and
 httpd.conf files and I can't seem to find anything, and as I mentioned
 above none of the previous posts on this topic have been resolved.
 
 Anyone?
 
 Thanks much in advance,
 Pablo
 
 Thursday, October 23, 2003, 4:05:13 AM, you wrote:
 PG Hi all.  I'd like to take a brief sentence to introduce myself
 first.
 PG My name is Pablo Gosse, and I've just recently joined the
 php-general
 PG list.  I've been using PHP since early 2000, and work as webmaster
 PG at the University of Northern British Columbia.
 
 PG I'm running into a problem with file uploads being handled in ascii
 PG rather than binary format.
 
 PG I've been writing a CMS for the past few months and the wysiwyg
 editor
 PG we're integrating has a very nice image manager built in
 PG (www.devedit.com).  However, the uploads are being transferred in
 ascii
 PG format instead of binary (or auto-detect) which is mangling all the
 PG images.
 
 PG I've done a lot of research into this but can't seem to pin down
 the
 PG problem.  I've looked through both my php.ini and httpd.conf and
 can't
 PG seem to find anything there that would remedy this problem.
 
 PG Does anyone have any advice as to where I should be looking to fix
 this
 PG problem?
 
 PG

RE: [PHP] Images being uploaded in ASCII format

2003-10-23 Thread Pablo Gosse
Thanks Raditha.  At least now I know I've been looking in the wrong
place!

I'll look forward to the perl script to see if it sheds any more light
on this situation.

I'm currently running Windoze, but when I boot to Linux later I'll try
Khexedit to see what I can come up with.

Cheers,
Pablo

-Original Message-
From: Raditha Dissanayake [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 23, 2003 10:48 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Images being uploaded in ASCII format

Hi Pablo

Pablo Gosse wrote:

Hi Raditha.  Thanks very much for your reply.  I've not been having
much
luck with this one.

welcome


This is how the images should appear:
http://web.unbc.ca/~gossep/sample_images/1.gif
http://web.unbc.ca/~gossep/sample_images/nav-02.jpg

And here is how they appear after being uploaded:
http://web.unbc.ca/~gossep/sample_images/1_uploaded.gif
http://web.unbc.ca/~gossep/sample_images/nav-02_uploaded.jpg

1.gif and 1_uploaded.gif differ by much as 4Kb in length! and the first 
difference occurs at byte number 1276. (I used cmp)


The results to me seem the same as if an image were FTPed in ascii mode
instead of binary mode (or auto-detect which would ultimately set the
mode to binary).

Though the output might look like that it's misleading because you are 
using HTTP post.  Unfortunately PHP does not allow access to raw POST 
data, else this can be debugged by looking at that data. I will mail you

(offlist) a small perl script that you can use to write out the POST to 
a temp file and may be help you get to the bottom of this.


I just downloaded the XVI32 hex editor, but what should I be looking
for
when I open the files and examine the contents?

Khexedit might be installed by default.

all the best



-- 
Raditha Dissanayake.

http://www.radinks.com/sftp/  |  http://www.raditha/megaupload/
Lean and mean Secure FTP applet with  |  Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB  |  with progress bar.

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

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



Re[2]: [PHP] Images being uploaded in ASCII format

2003-10-23 Thread Tom Rogers
Hi,

Friday, October 24, 2003, 2:11:43 AM, you wrote:
PG Hi Tom.

 make sure you have ENCTYPE=multipart/form-data in the form tag

PG Thanks for the tip, but that's not the problem.  My code is below, and
PG as you can see there is nothing in the code that would be causing this.
PG It has to be something in the server, and while there have been a few
PG posts to these lists about this problem, never a resolution for the
PG problem.

What operating system is the server running on?

-- 
regards,
Tom

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



Re[2]: [PHP] Images being uploaded in ASCII format

2003-10-23 Thread Tom Rogers
Hi,

Friday, October 24, 2003, 2:11:43 AM, you wrote:
PG Hi Tom.

 make sure you have ENCTYPE=multipart/form-data in the form tag

PG Thanks for the tip, but that's not the problem.  My code is below, and
PG as you can see there is nothing in the code that would be causing this.
PG It has to be something in the server, and while there have been a few
PG posts to these lists about this problem, never a resolution for the
PG problem.

PG Here's the code:

Another thing is to try move_uploaded_file() instead of copy, if your server is
on windows copy maybe doing strange things as copy needs /b to indicate binary,
just a guess.



-- 
regards,
Tom

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



Re: [PHP] Images being uploaded in ASCII format

2003-10-23 Thread Michael Mauch
Pablo Gosse wrote:
 Hi Raditha.  Thanks very much for your reply.  I've not been having much
 luck with this one.
 
 This is how the images should appear:
 http://web.unbc.ca/~gossep/sample_images/1.gif
 http://web.unbc.ca/~gossep/sample_images/nav-02.jpg
 
 And here is how they appear after being uploaded:
 http://web.unbc.ca/~gossep/sample_images/1_uploaded.gif
 http://web.unbc.ca/~gossep/sample_images/nav-02_uploaded.jpg
 
 The results to me seem the same as if an image were FTPed in ascii mode
 instead of binary mode (or auto-detect which would ultimately set the
 mode to binary).

Use strings to look at the files. This:

yPZ-7d33511600b6
Content-Disposition: form-data; name=upload; filename=C:\Documents and 
Settings\gossep\Desktop\ewimages\1.gif
Content-Type: image/gif
GIF89a

certainly doesn't belong in the image.

 Apache 2.0
 PHP 4.2.2

PHP 4.2.2 is 300 years old - I'm surprised that Apache 2 existed back
then. See http://www.php.net/manual/en/install.apache2.php.

Regards...
  Michael

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



[PHP] Images being uploaded in ASCII format

2003-10-22 Thread Pablo Gosse
Hi all.  I'd like to take a brief sentence to introduce myself first.
My name is Pablo Gosse, and I've just recently joined the php-general
list.  I've been using PHP since early 2000, and work as webmaster
at the University of Northern British Columbia.

I'm running into a problem with file uploads being handled in ascii
rather than binary format.

I've been writing a CMS for the past few months and the wysiwyg editor
we're integrating has a very nice image manager built in
(www.devedit.com).  However, the uploads are being transferred in ascii
format instead of binary (or auto-detect) which is mangling all the
images.

I've done a lot of research into this but can't seem to pin down the
problem.  I've looked through both my php.ini and httpd.conf and can't
seem to find anything there that would remedy this problem.

Does anyone have any advice as to where I should be looking to fix this
problem?

Thanks much in advance.

Cheers,
Pablo

---
Pablo Gosse
Webmaster
University of Northern British Columbia
250.960.5621
[EMAIL PROTECTED]
---

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



Re: [PHP] Images being uploaded in ASCII format

2003-10-22 Thread Tom Rogers
Hi,

Thursday, October 23, 2003, 4:05:13 AM, you wrote:
PG Hi all.  I'd like to take a brief sentence to introduce myself first.
PG My name is Pablo Gosse, and I've just recently joined the php-general
PG list.  I've been using PHP since early 2000, and work as webmaster
PG at the University of Northern British Columbia.

PG I'm running into a problem with file uploads being handled in ascii
PG rather than binary format.

PG I've been writing a CMS for the past few months and the wysiwyg editor
PG we're integrating has a very nice image manager built in
PG (www.devedit.com).  However, the uploads are being transferred in ascii
PG format instead of binary (or auto-detect) which is mangling all the
PG images.

PG I've done a lot of research into this but can't seem to pin down the
PG problem.  I've looked through both my php.ini and httpd.conf and can't
PG seem to find anything there that would remedy this problem.

PG Does anyone have any advice as to where I should be looking to fix this
PG problem?

PG Thanks much in advance.

PG Cheers,
PG Pablo

make sure you have ENCTYPE=multipart/form-data in the form tag

-- 
regards,
Tom

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



[PHP] images with gd for printing?

2003-08-15 Thread Merlin
Hi there,

I want to create images with GD and freetype ttf which are good enough for
printing .. about 150 dpi.

Does anybody know how to output the jpg with a higher resolution and a
determined output size?

Thanx in advance,

merlin



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



[PHP] Graduated fills using PHP Images

2003-08-15 Thread Adrian
Hi all!
 
Is it possible to have PHP creates an image that graduates 1 color to
another, such as create and images 100 pixels wide and in height which
fades red to green top to bottom?
 
Any help or suggestions would be really helpful.
 
Thanks 
 
Adrian
[EMAIL PROTECTED]
 
 


RE: [PHP] Graduated fills using PHP Images

2003-08-15 Thread Jay Blanchard
[snip]
Is it possible to have PHP creates an image that graduates 1 color to
another, such as create and images 100 pixels wide and in height which
fades red to green top to bottom?
[/snip]

http://us3.php.net/image

You could set the color index and the loop through (while incrementing)
each new index.  Seems awfully intensive though. I know that jpgraph
(http://www.aditus.nu/jpgraph/) can use gradiated backgrounds for some
of its output...perhaps you could look at the code included with the
class

HTH!

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



Re: [PHP] Graduated fills using PHP Images

2003-08-15 Thread Jaap van Ganswijk
At 2003-08-15 08:14 -0400, Adrian wrote:
Is it possible to have PHP creates an image that graduates 1 color to
another, such as create and images 100 pixels wide and in height which
fades red to green top to bottom?

It's possible. I have just been experimenting with
it using ImageCreateTrueColor().

See the manual:
http://www.php.net/manual/en/function.imagecreatetruecolor.php

You still have to use ImageColorAllocate() to get
a color but you can deallocate it right after usage
and you can use as many colors as you like (whereas
with normal 256 color images you can't use more
than 256). The process didn't noticably slow my
1 Ghz PC down.

I made some nice fades in two directions too:
http://www.chipdir.nl/adprov/adb/cdb/468_60/08en.png

BTW. I made it look like the upper text has been pressed
downward into the material and the lower text has been
pressed upward out of the material. (Using alpha
channel coloring.)

Let me know if you want to see the source code...




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



RE: [PHP] images in databases Flash via PHP

2003-07-23 Thread Luis Lebron
There a few different ways to do this. One method that we use here is to do
something like this in the embed/object tags

flash.swf?image=?php echo $image; ?

The php $image variable, of course, could be set by any method (post/get, db
query, etc...)


Luis

-Original Message-
From: Tim Baker [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 22, 2003 12:01 PM
To: '[EMAIL PROTECTED]'
Subject: [PHP] images in databases  Flash via PHP



I was wondering - are there any good tutorials/examples of serving 
updating images from a mySQL database via PHP?  I assume this is possible,
but I'm almost a newbie having not used PHP/mySQL for ages with some
knowledge but would like to know more...

Also now Flash MX can dynamically take JPEGs and MPEGs in
'dynamically' at runtime now, anyone combined this with PHP/mySQL to serve
images? (I'd guess someone or many people have :-) 

I've done it from the Flash only side, loading variables and
images/music, building modular duplicated movieclips etc. and want to do the
next step which is to combine that with databases (I'm currently using text
files, files on a webserver etc.)

thanks

Tim Baker 

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


[PHP] images in databases Flash via PHP

2003-07-22 Thread Tim Baker

I was wondering - are there any good tutorials/examples of serving 
updating images from a mySQL database via PHP?  I assume this is possible,
but I'm almost a newbie having not used PHP/mySQL for ages with some
knowledge but would like to know more...

Also now Flash MX can dynamically take JPEGs and MPEGs in
'dynamically' at runtime now, anyone combined this with PHP/mySQL to serve
images? (I'd guess someone or many people have :-) 

I've done it from the Flash only side, loading variables and
images/music, building modular duplicated movieclips etc. and want to do the
next step which is to combine that with databases (I'm currently using text
files, files on a webserver etc.)

thanks

Tim Baker 

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



RE: [PHP] images in databases Flash via PHP

2003-07-22 Thread Boaz Yahav
Saving Images in MySQL
http://www.weberdev.com/ViewArticle.php3?ArticleID=3

Sincerely
 
berber
 
Visit http://www.weberdev.com/ Today!!!
To see where PHP might take you tomorrow.
Share your code : http://addexample.weberdev.com


-Original Message-
From: Tim Baker [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 22, 2003 7:01 PM
To: '[EMAIL PROTECTED]'
Subject: [PHP] images in databases  Flash via PHP



I was wondering - are there any good tutorials/examples of
serving  updating images from a mySQL database via PHP?  I assume this
is possible, but I'm almost a newbie having not used PHP/mySQL for ages
with some knowledge but would like to know more...

Also now Flash MX can dynamically take JPEGs and MPEGs in
'dynamically' at runtime now, anyone combined this with PHP/mySQL to
serve images? (I'd guess someone or many people have :-) 

I've done it from the Flash only side, loading variables and
images/music, building modular duplicated movieclips etc. and want to do
the next step which is to combine that with databases (I'm currently
using text files, files on a webserver etc.)

thanks

Tim Baker 

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

 

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



[PHP] images..

2003-06-24 Thread Edward Peloke
I asked this question last week and thought I had it fixed but it still
doesn't seem to work.  I use the code below to allow the user to upload
their images, once uploaded the images don't look nearly as good as they did
before uploading.  Another interesting thing is that if you right click on
the images, they don't give you the option of saving the image, only saving
as background but maybe that is because they are jpegs.  Do I need to use a
higher resolution picture?

if(!empty($myimage)){
$id=$HTTP_GET_VARS['id'];
$imgname=image_.$id..jpg;
copy($myimage,$imgname);
unlink($myimage);
function thumbnail($i,$nw,$p,$nn) {
$img=imagecreatefromjpeg($i);
$ow=imagesx($img);
$oh=imagesy($img);
$scale=$nw/$ow;
$nh=ceil($oh*$scale);
$newimg=imagecreatetruecolor($nw,$nh);
imagecopyresized($newimg,$img,0,0,0,0,$nw,$nh,$ow,$oh);
imagejpeg($newimg, $nn);
return true;
}

#thumbnail(filetouse,newwidth,newpath,newname);
thumbnail($imgname,100,/imges/,t_.$imgname);
thumbnail($imgname,250,/imges/,$imgname);

here is the site if anyone is interested,
http://www.wardsmotorsports.com

Thanks,
Eddie


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



Re: [PHP] images..

2003-06-24 Thread Jason Wong
On Tuesday 24 June 2003 23:35, Edward Peloke wrote:

 I asked this question last week and thought I had it fixed but it still
 doesn't seem to work.  I use the code below to allow the user to upload
 their images, once uploaded the images don't look nearly as good as they
 did before uploading.  Another interesting thing is that if you right click
 on the images, they don't give you the option of saving the image, only
 saving as background but maybe that is because they are jpegs.  Do I need
 to use a higher resolution picture?

 imagecopyresized($newimg,$img,0,0,0,0,$nw,$nh,$ow,$oh);

imagecopyresampled()

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--


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



RE: [PHP] Images out side the wwwroot

2003-03-10 Thread Don Read

On 10-Mar-2003 Philip J. Newman wrote:
 If i was to use PHP to call all my images from out side the wwwroot, dose
 anyone have a method that they use?
 

show.php
-
?php

$rcsid='$Id: show.php,v 1.1 2002/02/14 21:20:26 dread Exp dread $';

// $Log: show.php,v 2002/02/14 21:20:26 dread $
// Revision 1.1dread
// Initial revision
//

error_reporting(0);

// where is the base directory of the images?
$imgdir='/usr/local/private/image';

//  Allow a sub-directory from $imgdir?
$allowpath= 0;

// Allow searching for extention ? *not implemented*
$allowsearch= 0;

$mimetype=array(
'jpeg' = 'image/jpeg',
'jpg'  = 'image/jpeg',
'gif'  = 'image/gif',
'mpeg' = 'video/mpeg',
'mpg'  = 'video/mpeg',
'mov'  = 'video/quicktime',
//  'avi'  = 'video/avi',
'avi'  = 'video/x-msvideo',
'wmv'  = 'video/x-ms-wmv',
'asf'  = 'video/x-ms-asf',
'png'  = 'image/png'
);


if (! isset($id))
die('no id.');

$id= urldecode($id);
$id= str_replace('../', '', $id); // fix the dodgy stuff
$id= trim($id);

if (! ($allowpath) )
$id= basename($id);

$ext= substr(strrchr($id, '.'), 1);
$path= $imgdir .'/' .$id;

if ($handle= fopen($path, 'r')) {

Header('Content-type: ' .$mimetype[$ext]);
Header(Content-Disposition: inline; filename= .basename($id));

fpassthru($handle);
fclose($handle);
}
?


call it as 'show.php?id=secretimg.jpeg' or use 
IMG SRC=show.php?id=secretimg.jpeg 

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



[PHP] Images out side the wwwroot

2003-03-09 Thread Philip J. Newman
If i was to use PHP to call all my images from out side the wwwroot, dose
anyone have a method that they use?

--
Philip J. Newman.
Head Developer
[EMAIL PROTECTED]

+64 (9) 576 9491
+64 021-048-3999

--
Friends are like stars
You can't allways see them,
but they are always there.

--
Websites:

PhilipNZ.com - Design.
http://www.philipnz.com/
[EMAIL PROTECTED]

Philip's Domain // Internet Project.
http://www.philipsdomain.com/
[EMAIL PROTECTED]

Vital Kiwi / NEWMAN.NET.NZ.
http://www.newman.net.nz/
[EMAIL PROTECTED]



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



Re: [PHP] Images out side the wwwroot

2003-03-09 Thread - Edwin
Philip J. Newman [EMAIL PROTECTED] wrote:

 If i was to use PHP to call all my images from out side the 
 wwwroot, dose anyone have a method that they use?

By using an absolute path?

- E

__
Do You Yahoo!?
Yahoo! BB is Broadband by Yahoo!  http://bb.yahoo.co.jp/


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



[PHP] Images

2003-02-14 Thread Lucas Lain
I am thinking in making some statistics graphics in php ... is there any 
library that i can use?
thanks

L.L.

--
Lucas Lain
[EMAIL PROTECTED]



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



Re: [PHP] Images

2003-02-14 Thread Jason Wong
On Saturday 15 February 2003 02:35, Lucas Lain wrote:
 I am thinking in making some statistics graphics in php ... is there any
 library that i can use?
 thanks

jpgraph

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Most people deserve each other.
-- Shirley
*/


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




Re: [PHP] Images

2003-02-14 Thread Lucas Lain
jpgraph professional license???
other FREE idea???

Jason Wong wrote:


On Saturday 15 February 2003 02:35, Lucas Lain wrote:


I am thinking in making some statistics graphics in php ... is there any
library that i can use?
thanks



jpgraph



--
Lucas Lain
[EMAIL PROTECTED]




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




  1   2   >