Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm, apache force chunked, nrao wwwxxx, xxxxxdup, procmail change subject header, wwwXxx not20, Wwwxxx.doks sas, linux raid resync after reboot

Links

XODOX
Impressum

#1: Introduction, and help request

Posted on 2011-10-14 10:51:40 by sari.csaba

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

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:dt=3D"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40"><head><meta =
http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1"><meta name=3DGenerator content=3D"Microsoft Word =
12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
span.E-mailStlus17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
..MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:1396971658;
mso-list-type:hybrid;
mso-list-template-ids:-1790022838 544656610 68026371 68026373 68026369 =
68026371 68026373 68026369 68026371 68026373;}
@list l0:level1
{mso-level-start-at:10;
mso-level-number-format:bullet;
mso-level-text:-;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-font-family:Calibri;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DHU link=3Dblue =
vlink=3Dpurple><div class=3DWordSection1><p class=3DMsoNormal><span =
lang=3DEN-US>Dear Listmembers, <o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US>First, let me introduce myself: my =
name is Csaba S=E1ri, and I&#8217;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. =
<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US>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&#8217;m =
using EXIF, GD for manipulating images &#8211; and everything works =
well, only allowed type of images could be uploaded, with max 500k size. =
<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US>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&#8217;s a standard $post, then move to a designated location, =
transform to this sizes): <o:p></o:p></span></p><p =
class=3DMsoListParagraph style=3D'text-indent:-18.0pt;mso-list:l0 level1 =
lfo1'><![if !supportLists]><span lang=3DEN-US><span =
style=3D'mso-list:Ignore'>-<span style=3D'font:7.0pt "Times New =
Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
</span></span></span><![endif]><span lang=3DEN-US>resize the original =
one for a 50x50px small thumb<o:p></o:p></span></p><p =
class=3DMsoListParagraph style=3D'text-indent:-18.0pt;mso-list:l0 level1 =
lfo1'><![if !supportLists]><span lang=3DEN-US><span =
style=3D'mso-list:Ignore'>-<span style=3D'font:7.0pt "Times New =
Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
</span></span></span><![endif]><span lang=3DEN-US>resize the original =
one for a 128x128px medium thumb<o:p></o:p></span></p><p =
class=3DMsoListParagraph style=3D'text-indent:-18.0pt;mso-list:l0 level1 =
lfo1'><![if !supportLists]><span lang=3DEN-US><span =
style=3D'mso-list:Ignore'>-<span style=3D'font:7.0pt "Times New =
Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
</span></span></span><![endif]><span lang=3DEN-US>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)<o:p></o:p></span></p><p class=3DMsoListParagraph =
style=3D'text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if =
!supportLists]><span lang=3DEN-US><span style=3D'mso-list:Ignore'>-<span =
style=3D'font:7.0pt "Times New =
Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
</span></span></span><![endif]><span lang=3DEN-US>extra: there is a =
&#8216;cut profile image from the original image&#8217; &#8211; like in =
Facebook &#8211; function. <o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US>After resizing complete, I&#8217;m =
escaping binary with pg_escape_bytea(), INSERT to the table: =
<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US>[code]<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal =
style=3D'text-indent:35.4pt'><span lang=3DEN-US>pg_query($dbconn, =
&quot;begin&quot;);<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US>              =A0 =
              =A0 <o:p></o:p></span></p><p =
class=3DMsoNormal><span =
lang=3DEN-US>              =A0 $query =3D =
&quot;INSERT INTO users_picturesalbums_pictures <o:p></o:p></span></p><p =
class=3DMsoNormal style=3D'margin-left:106.2pt;text-indent:35.4pt'><span =
lang=3DEN-US>(album_id, title, photo, photo_50, photo_128, photo_900, =
inocent, photo_name, mimetype, enable_comments) <o:p></o:p></span></p><p =
class=3DMsoNormal style=3D'margin-left:70.8pt;text-indent:35.4pt'><span =
lang=3DEN-US>VALUES<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US>              =A0=A 0    =
                         =A0=
=A0               =A0 ('&quot; . $albumid . =
&quot;', '&quot; . pg_escape_string($title) . &quot;', E'&quot; . =
$pic_origin . &quot;', E'&quot; . $pic_50 . &quot;', E'&quot; . $pic_128 =
.. &quot;', E'&quot; . $pic_900 . &quot;','&quot; . $inocent . =
&quot;','&quot; . pg_escape_string($name) . &quot;','&quot; . $mimetype =
.. &quot;','&quot; . $enablecomments . =
&quot;');&quot;;<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US>              =A0=A 0    =
                         =A0=
=A0 <o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US>              =A0 $result =3D =
pg_query($dbconn, $query);<o:p></o:p></span></p><p =
class=3DMsoNormal><span =
lang=3DEN-US>              =A0=A 0    =
                         =A0=
                =A0 =
<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US>              =A0 =
pg_query($dbconn, &quot;commit&quot;);<o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US>[/code]<o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US>After this transaction is complete, =
I delete the temporary files, everything seems fine &#8211; 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. =
<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US>I&#8217;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&#8217;t =
know what did I wrong, or what else can I set. <o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US>If you have any suggestion, advice, =
experience please send me. <o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US>Thank you in =
advance,<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US>Kind regards,<o:p></o:p></span></p><p =
class=3DMsoNormal><span =
lang=3DEN-US>Csaba<o:p></o:p></span></p></div></body></html>
------=_NextPart_000_030D_01CC8A5F.41518710--

Report this message

#2: Re: Introduction, and help request

Posted on 2011-10-17 00:03:56 by dmagick

> 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.

You could try the suggestions mentioned here:

http://www.php.net/manual/en/function.pg-escape-bytea.php#89 036


--=20
Postgresql & php tutorials
http://www.designmagick.com/


--=20
Sent via pgsql-php mailing list (pgsql-php@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php

Report this message

#3: Re: Introduction, and help request

Posted on 2011-10-17 13:37:46 by sari.csaba

Dear Chris,

thank you for your response, buti t wasn't the right solution :-(... First,
I just reconfigured the postgre server, with more memory, buffers, etc, and
than I just lowered the image resolutions with GD, and now it's working. My
idea was this: somewhere a buffer (or something like this, OR there is a
timeout somewhere, but I changed all related apache and PHP settings) is
small, to accept all the image datas from the client (???), and if I make
smaller pictures, it could be ok. And it's works now fine.=20

Thank you all the suggestions.=20

Regards,
Csaba

-----Original Message-----
From: pgsql-php-owner@postgresql.org [mailto:pgsql-php-owner@postgresql.org]
On Behalf Of Chris
Sent: Monday, October 17, 2011 12:04 AM
To: pgsql-php@postgresql.org
Subject: Re: [PHP] Introduction, and help request


> 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.

You could try the suggestions mentioned here:

http://www.php.net/manual/en/function.pg-escape-bytea.php#89 036


--=20
Postgresql & php tutorials
http://www.designmagick.com/


--=20
Sent via pgsql-php mailing list (pgsql-php@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php


--=20
Sent via pgsql-php mailing list (pgsql-php@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php

Report this message