pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Introduction, and help request
3+ messages / 2 participants
[nested] [flat]

* Introduction, and help request
@ 2011-10-14 08:51  Sári Csaba <sari.csaba@wishdoo.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Sári Csaba @ 2011-10-14 08:51 UTC (permalink / raw)
  To: pgsql-php

Dear Listmembers, 

 

First, let me introduce myself: my name is Csaba Sári, 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");

                                

                $query = "INSERT INTO users_picturesalbums_pictures 

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

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 . "');";

                                               

                $result = pg_query($dbconn, $query);

                                                               

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

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Introduction, and help request
@ 2011-10-16 22:03  Chris <dmagick@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Chris @ 2011-10-16 22:03 UTC (permalink / raw)
  To: pgsql-php


> 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 ¾ 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#89036


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




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Introduction, and help request
@ 2011-10-17 11:37  Sári Csaba <sari.csaba@wishdoo.com>
  parent: Chris <dmagick@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Sári Csaba @ 2011-10-17 11:37 UTC (permalink / raw)
  To: 'Chris' <dmagick@gmail.com>; pgsql-php

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. 

Thank you all the suggestions. 

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 – 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 ¾ 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#89036


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


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




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2011-10-17 11:37 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-10-14 08:51 Introduction, and help request Sári Csaba <sari.csaba@wishdoo.com>
2011-10-16 22:03 Re: Introduction, and help request Chris <dmagick@gmail.com>
2011-10-17 11:37 ` Sári Csaba <sari.csaba@wishdoo.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox