joining multiple jpg images
Hi guys,
I'm fairly new to php, i'm looking for some pointers to do the following
I have a database with jpegs in and am dynamically generating a page to show
the pics, but as you are possibly aware that each picture needs to go to
the database to download.
therefore it makes more sense to go to hte database pull my 1-6 images then
join them into 1 long jpg , total size will be about 20-30k
this means i can just use 1 picture link to dl a "strip" of generated
pictures.
1. I have to get the pictures from a database, no they cannot be kept on the
site
2. I do not need a gallery system it is overly complex for my needs.
steve
Re: joining multiple jpg images
On Sat, 09 Jun 2007 02:59:20 +0200, steve <steve [at] aol.com> wrote:
> Hi guys,
>
> I'm fairly new to php, i'm looking for some pointers to do the following
>
> I have a database with jpegs in and am dynamically generating a page to
> show
> the pics, but as you are possibly aware that each picture needs to go
> to
> the database to download.
>
> therefore it makes more sense to go to hte database pull my 1-6 images
> then
> join them into 1 long jpg , total size will be about 20-30k
>
> this means i can just use 1 picture link to dl a "strip" of generated
> pictures.
Making a 'strip', without using any files:
- if you don't want to create temporary files, register a custom stream to
your data (database info captured in an array for instance):
http://www.php.net/manual/en/function.stream-wrapper-registe r.php
- now you can use the normal imagecreatefrom*() functions with your
registered stream.
- decide a width (or height, depending on direction) for your strip.
- calculate the height of all images resized to that width (use
imagesx()/imagesy() or getimagesize().
- create a new image with the width and the sum of the heights.
- paste the other images in it using imagecopyresampled()
- turn on output buffering, and capture the output of imagejpeg()(*gif(),
etc), and save it to the database.
All pretty simple, only the registering of a stream might be a little bit
tricky if you haven't done it before. It's actually a lot easier then it
looks.
--
Rik Wasmus