Re: dynamic image quality from blobs?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Dave,

I do not agree. Images in DB are a great thing. You can play around with
them, put watermarks or try to create a dynamic quality delivery for each
user (like I am trying right now:-) Performance is great and it keeps things
way more easy!

Cheers,

Merlin

PS: Has anybody an idea on how to create this dynamic quality image
delivery? All posts on this topic are not relevant to the problem;-((


----- Original Message -----
From: "Dave Carrera" <dave@ephgroup.com>
To: "'Merlin'" <news.groups@web.de>
Cc: <php-db@lists.php.net>
Sent: Wednesday, May 14, 2003 9:03 AM
Subject: RE:  dynamic image quality from blobs?


Why are you using blob fields for image storage?

It is far better to upload / replicate the image into dirs.

This dramatically reduces the size of the db and speed of delivery.

As you are using GD2 try this as an alternative method for your delivery
method. I posted this solution a few days ago but here it is again.

Prog flow:

Form has FILE input field named "picture" to find local jpg image.
On submit original file is uploaded to ./big dir
Then a thumbnail of 100x70 pixels is created and placed into ./thumb dir All
files are named with a unique filename. Then path info only entered into
MySql db for recall later, I never wanted to load images to a db, bad
idea...

--- Start ---
If(isset($_POST[picture]){
$bigdir = "./prodimg/big";
$tumbdir = "./prodimg/thumb";
$tw = 70;
$th = 100;
if(isset($_POST[addproduct])){
if(isset($_FILES[picture])){
$fileName = explode(".", $_FILES['picture']['name']);
$name = str_replace(' ', '_', $fileName[0]);

$img_orig_size = getimagesize($_FILES['picture']['tmp_name']);
$img_orig_width = $img_orig_size[0];
$img_orig_height = $img_orig_size[1];

$img_original = ImageCreateFromJpeg($_FILES['picture']['tmp_name']);
$image_stored = time() . "_$name.jpg";
ImageJPEG($img_original, ".$bigdir/$image_stored",100);

$img_resized = ImageCreateTrueColor($tw, $th);

imagecopyresampled($img_resized,
ImageCreateFromJpeg($_FILES['picture']['tmp_name']), 0 , 0 , 0 , 0, $tw,
$th, $img_orig_width, $img_orig_height); $img_name = "tn_$image_stored";

Imagejpeg($img_resized, ".$tumbdir/$img_name",85);

ImageDestroy($img_resized);

$mysql_thumb = "$tumbdir/$img_name"; //thumbnail path to write to mysql
$mysql_big = "$bigdir/$image_stored"; // original path to write to mysql //
Do your own mysql_query here }
--- End ---

You will need to 777 both the thumb and big dir. Also note the use of
"ImageCreateTrueColor". This is tons better than just using "ImageCreate",
also note the 85. This sets the jpg compression. I found this value gives a
good balance between visual quality and file size. $_POST[picture] comes
from an form with a field of this name. and remember to add the
ENCTYPE="multipart/form-data" to your form.

Hope this helps

Dave Carrera

http://www.ephgroup.com
Secure Hosting Accounts for everyone.

-----Original Message-----
From: Merlin [mailto:news.groups@web.de]
Sent: 14 May 2003 07:37
To: Maxim Maletsky
Cc: php-db@lists.php.net
Subject: Re:  dynamic image quality from blobs?


I am using GD2 for this. However, does not work in this case?!

Merlin


----- Original Message -----
From: "Maxim Maletsky" <subscriptions@phpbeginner.com>
To: "Merlin" <news.groups@web.de>
Cc: <php-db@lists.php.net>
Sent: Tuesday, May 13, 2003 11:24 PM
Subject: Re:  dynamic image quality from blobs?


>
> You should use GD2 for this. Check what you've got on your PHP's
> installation.
>
> Maxim Maletsky
> maxim@php.net
>
>
> On Tue, 13 May 2003 22:11:58 +0200
> "Merlin" <news.groups@web.de> wrote:
>
> > Hi there,
> >
> > I am trying to set a dynamic image quality. My images are stored as
blobs in
> > a mysql db. Till now the images are just echoed out to
> > the browser. This workes. Now I would like to add dynamic quality,
therefore
> > I tryed to output them with imagejpeg.
> > Unfortuanetelly this does not work at all, and I cant get behind the
> > problem.
> >
> > Has anybody a good idea?
> >
> > Thanx,
> >
> > Merlin
> >
> >
############################################################################
> > ####################
> > # output
> > header("Content-type: $file_type");
> > echo $picture_blob;
> > // this would not work:
> > // imagejpeg($picture_blob,"",10);
> >
############################################################################
> > ####################
> >
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> --
> Maxim Maletsky
> maxim@php.net
>
>


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.478 / Virus Database: 275 - Release Date: 06/05/2003


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.478 / Virus Database: 275 - Release Date: 06/05/2003



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




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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux