Hi George,

George Whiffen wrote:

> I'm confused. Is your problem serving up the images in your database to the web or 
>writing them out
> to files on the server?


Sorry for the confusion..  It was in writing out the database images to 
files on the server.  This is where my problem lies..


> If it's serving images, I would expect you to have: 
> select myimage from db
> Header("Content-type: image/jpeg");
> echo $myrow[myimage];
> exit();


Yes..  This is consistent with what is done in the rest of the script 
and indeed what any of other tutorials describe..


> If it's writing from the db to a real file on your server, I would expect: 
> select myimage from db
> open myfile
> write $myrow[myimage];
> close myfile


I've tried something like this:

$connection = mysql_connect("host", "user", "pwd");
mysql_select_db("dbname");
$query = 'SELECT imagefiled FROM imagetabel WHERE id = '.$id;
$result = mysql_query($query);
$row = mysql_fetch_row($result);

$fd = fopen( "$File.tmb", "r+");
$tmb = addslashes(fwrite($fd, $row[0]));
fclose($fd);

However, I can't view the file that is saved (there is a file saved each 
time I do this, but can't tell if it is the appropriate file)..
   I assumed that I needed to include the header file..

The template also doesn't seem to work, but that is because of an error 
I'm getting an error when i run this on the server (the expression of 
what I am trying to do with the system() command below):

djpeg -pnm ReThumbnail.jpg | pnmscale -xscale .1 -yscale .1 | cjpeg > 
ReThumbnail.jpg.tmb

Corrupt JPEG data: 67 extraneous bytes before marker 0xc2
Quantization table 0x01 was not defined
pnmscale: Command not found.
Empty input file

I don't know what this all means


> The Header is just for the web, to tell the browser or other client what kind of 
>file it is getting
> from your php script since it is not the expected type automatically supplied by the 
>web-server
> (text/html).  Real physical files don't need a header.  The web servers 
>automatically generate
> appropriate headers for real image files based on the file extension before they 
>send them out over
> the web.


So, why can't I see this the 17159 bytes of this image then:
http://www.wtoaction.org/caravan2001/ReThumbnail.jpg

I was assuming that I couldn't see it because I didn't have the header. 
  I was just trying to use ImageJPEG to force in a header.  It would be 
far easier to just write the contents of an image from a database and 
insert them into a file..


> Does that make sense, or have I completely missed the point?


You got the point.. Thanks for your help..  Still not there yet though..

Mike


> Mike Gifford wrote:
> 
>>Hello,
>>
>>I've got a number of images in a database..  Ultimately what I would
>>like to do is be able to resize the image that is already in the
>>database and then insert that image into another field.
>>
>>Uploading the files generally inserts these both at the same time,
>>however I need to create a number of new thumbprints based on a
>>different scale.
>>
>>What I thought would be easiest would be to take the image, save it to
>>filename.jpg and then run the thumbnailing script on it.
>>
>>I think that this would look like the following:
>>
>><?php
>>// There's other DB stuff here, but this isn't important
>>$Images = stripslashes($row[0]);
>>$File = "ReThumbnail.jpg";
>>
>>// Create JPG image
>>ImageJPEG(imagecreatefromstring($Images), $File);
>>
>>// Scale image
>>system("djpeg -pnm $File | pnmscale -xscale .1 -yscale .1 | cjpeg >
>>$File.tmb");
>>
>>// Write thumbprint
>>$fd = fopen( "$File.tmb", "r+");
>>$tmb = addslashes(fread($fd, filesize("$File.tmb")));
>>fclose($fd);
>>
>>// Insert Thumbprint image into database
>>$sql = "UPDATE Images SET Thumbnail='$tmb' WHERE ID=$ID";
>>// There's other DB Stuff here too...
>>?>
>>
>>I'm really quite stuch here..
>>
>>How do you take a db image of a database and create a physical jpg file?
>>  I think I'm getting messed up by the header in:
>>
>>Header("Content-type: image/jpeg");
>>echo $Images;
>>
>>I can't figure out how to create the header.  There's lots of examples
>>of how to do the above, but I have yet to stumble across an example
>>which allows you to write the header into a file....
>>
>>Suggestions would be appreciated..
>>
>>Mike
>>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to