Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 7C016B5DBC8 for ; Fri, 14 Oct 2011 05:52:12 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 66180-08 for ; Fri, 14 Oct 2011 08:52:05 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mo-p00-ob.rzone.de (mo-p00-ob.rzone.de [81.169.146.161]) by mail.postgresql.org (Postfix) with ESMTP id 58B48B5DBC2 for ; Fri, 14 Oct 2011 05:52:04 -0300 (ADT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1318582322; l=13188; s=domk; d=wishdoo.com; h=Content-Type:MIME-Version:Date:Subject:To:From:X-RZG-CLASS-ID: X-RZG-AUTH; bh=NAoUEw7lnQYA8j+MFQW1gQ36jfw=; b=tNFTrfZEhAnlRb89INiK8XuX2RIVYPL0ce6TFL6DXTokuhUU1wZ/arwQC1oMlD+psju 4DPWXKrTInaKlrCyHeVMGTIyio9SfPpIPd72maE13zZrU7QjvWQ5+B75Joy0eitAE+1kc WC4nUVwiD5oEdbGejf6HKyRBN59lc1CUSq0= X-RZG-AUTH: :P20WfA6raP5jJDNiRKsUjEaBpE8RcJz3bqXbilRfa2ATHR79V3FuKDz9jH9M2twb X-RZG-CLASS-ID: mo00 Received: from Redemption (catv-178-48-107-88.catv.broadband.hu [178.48.107.88]) by smtp.strato.de (klopstock mo31) (RZmta 26.10 AUTH) with ESMTPA id e01608n9E854bY for ; Fri, 14 Oct 2011 10:51:43 +0200 (MEST) From: =?ISO-8859-1?Q?S=E1ri_Csaba?= To: Subject: Introduction, and help request Date: Fri, 14 Oct 2011 10:51:40 +0200 Message-ID: <030c01cc8a4e$7dc8b710$795a2530$@csaba@wishdoo.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_030D_01CC8A5F.41518710" X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcyKTn1yAQfyZzeYQBOrRfu7Onv7CQ== Content-Language: hu X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, MSGID_MULTIPLE_AT=0.001, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201110/1 X-Sequence-Number: 4217 This is a multi-part message in MIME format. ------=_NextPart_000_030D_01CC8A5F.41518710 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable Dear Listmembers,=20 =20 First, let me introduce myself: my name is Csaba S=E1ri, and I=92m 34 = years old freelancer webdeveloper. I have a 3 years old Son, and I live in = Hungary, Budapest. My English is not so good, so I apologize for it.=20 =20 I have a project currently, where I have to store images (png, jpg and = gif) in Postgre, and it is in PHP5 with Jquery. I=92m using EXIF, GD for manipulating images =96 and everything works well, only allowed type of = images could be uploaded, with max 500k size.=20 =20 Unfortunately somebody else has designed the database, and it cannot be modified anymore, and my problem is the following: the images has been stored is bytea field, not like LO. If somebody uploading an image, I = have to resize the images for 3 different sizes (it=92s a standard $post, = then move to a designated location, transform to this sizes):=20 - resize the original one for a 50x50px small thumb - resize the original one for a 128x128px medium thumb - and resize the original one for a 900x900px large thumb (of course if the image is larger than the proper size, if it is smaller I = just copy it) - extra: there is a =91cut profile image from the original = image=92 =96 like in Facebook =96 function.=20 =20 After resizing complete, I=92m escaping binary with pg_escape_bytea(), = INSERT to the table:=20 [code] =20 pg_query($dbconn, "begin"); =20 $query =3D "INSERT INTO users_picturesalbums_pictures=20 (album_id, title, photo, photo_50, photo_128, photo_900, inocent, photo_name, mimetype, enable_comments)=20 VALUES ('" . $albumid . "', '" . pg_escape_string($title) . "', E'" . $pic_origin . = "', E'" . $pic_50 . "', E'" . $pic_128 . "', E'" . $pic_900 . "','" . = $inocent . "','" . pg_escape_string($name) . "','" . $mimetype . "','" . $enablecomments . "');"; =20 $result =3D pg_query($dbconn, $query); =20 pg_query($dbconn, "commit"); =20 [/code] =20 After this transaction is complete, I delete the temporary files, = everything seems fine =96 BUT the image in the table looks like broken. When I want = to display it, sometimes the small one (50x50), or the medium one (128x128) looks like, which is broken at the half of the image upload, or =BE of = the image upload. I checked the temporary files before I delete it, they are = ok, so the problem is not with the image manipulation.=20 =20 I=92ve try to tune the PostgreSQL conf (larger mem, workmem, buffers = etc.), php.ini, apache, but always the same result: sometimes upload is ok, sometimes the upload broke. And I don=92t know what did I wrong, or what = else can I set.=20 =20 If you have any suggestion, advice, experience please send me.=20 =20 Thank you in advance, =20 Kind regards, Csaba ------=_NextPart_000_030D_01CC8A5F.41518710 Content-Type: text/html; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable

Dear Listmembers,

 

First, let me introduce myself: my = name is Csaba S=E1ri, and I’m 34 years old freelancer = webdeveloper. I have a 3 years old Son, and I live in Hungary, Budapest. = My English is not so good, so I apologize for it. =

 

I have a project currently, where I have to store images = (png, jpg and gif) in Postgre, and it is in PHP5 with Jquery. I’m = using EXIF, GD for manipulating images – and everything works = well, only allowed type of images could be uploaded, with max 500k size. =

 

Unfortunately somebody else has designed the database, and = it cannot be modified anymore, and my problem is the following: the = images has been stored is bytea field, not like LO. If somebody = uploading an image, I have to resize the images for 3 different sizes = (it’s a standard $post, then move to a designated location, = transform to this sizes):

-          = resize the original = one for a 50x50px small thumb

-          = resize the original = one for a 128x128px medium thumb

-          = and resize the = original one for a 900x900px large thumb (of course if the image is = larger than the proper size, if it is smaller I just copy = it)

-          = extra: there is a = ‘cut profile image from the original image’ – like in = Facebook – function.

 

After resizing complete, I’m = escaping binary with pg_escape_bytea(), INSERT to the table: =

[code]

 

pg_query($dbconn, = "begin");

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 = =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 $query =3D = "INSERT INTO users_picturesalbums_pictures

(album_id, title, photo, photo_50, photo_128, photo_900, = inocent, photo_name, mimetype, enable_comments)

VALUES

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ('" . $albumid . = "', '" . pg_escape_string($title) . "', E'" . = $pic_origin . "', E'" . $pic_50 . "', E'" . $pic_128 = . "', E'" . $pic_900 . "','" . $inocent . = "','" . pg_escape_string($name) . "','" . $mimetype = . "','" . $enablecomments . = "');";

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 $result =3D = pg_query($dbconn, $query);

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 = pg_query($dbconn, "commit");

 

[/code]

 

After this transaction is complete, = I delete the temporary files, everything seems fine – BUT the = image in the table looks like broken. When I want to display it, = sometimes the small one (50x50), or the medium one (128x128) looks like, = which is broken at the half of the image upload, or =BE of the image = upload. I checked the temporary files before I delete it, they are ok, = so the problem is not with the image manipulation. =

 

I’ve try to tune the PostgreSQL conf (larger mem, = workmem, buffers etc.), php.ini, apache, but always the same result: = sometimes upload is ok, sometimes the upload broke. And I don’t = know what did I wrong, or what else can I set.

 

If you have any suggestion, advice, = experience please send me.

 

Thank you in = advance,

 

Kind regards,

Csaba

------=_NextPart_000_030D_01CC8A5F.41518710--