You are here: Re: joining multiple jpg images « All PHP « IT news, forums, messages
Re: joining multiple jpg images

Posted by Rik on 06/16/07 12:42

On Sat, 09 Jun 2007 02:59:20 +0200, steve <steve@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-register.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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация