How to join two images with "GD::Image"

How to join two images with "GD::Image"

am 25.06.2007 10:36:25 von Francesco Moi

Hi.

I've got two images on my Hard Disk ('pic1.jpg' and 'pic2.jpg') and
would like to join them both into a unique one ('mypic.jpg').

Is it possible with 'GD::Image'? Thank you very much.

Re: How to join two images with "GD::Image"

am 25.06.2007 11:49:45 von Gunnar Hjalmarsson

Francesco Moi wrote:
> I've got two images on my Hard Disk ('pic1.jpg' and 'pic2.jpg') and
> would like to join them both into a unique one ('mypic.jpg').
>
> Is it possible with 'GD::Image'?

Which efforts did you make to find out before asking here?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Re: How to join two images with "GD::Image"

am 25.06.2007 12:32:09 von Francesco Moi

>
> Which efforts did you make to find out before asking here?

I've been browsing
http://search.cpan.org/dist/GD/GD.pm

I didn't find out anything about "joining two images".

I've been searching with Google:
- "join two images" GD::Image perl
- join images GD::Image perl

Re: How to join two images with "GD::Image"

am 25.06.2007 13:07:10 von Martien Verbruggen

On Mon, 25 Jun 2007 10:32:09 -0000,
Francesco Moi wrote:
>>
>> Which efforts did you make to find out before asking here?
>
> I've been browsing
> http://search.cpan.org/dist/GD/GD.pm
>
> I didn't find out anything about "joining two images".

You seem to be making the assumption that "joining two images" is
somehow standard graphics terminology. It isn't as far as I know. I am
assuming that to "join" two images, to you, means displaying them side
by side?

The above link has the complete documentation for GD::Image. What you're
looking for, if the above assumption is right, is the copy() method.

Create a new image, large enough to hold the 'joined' result. Use the
copy() method to put the old images in the appropriate place. Maybe you
need copyMerge if you want them to overlap.

For more complex combination methods between images, you might want to
look at Image::Magick or maybe Imager.

Martien
--
|
Martien Verbruggen | The problem with sharks is that they are too
| large to get to the shallow end of the gene
| pool. -- Scott R. Godin

Re: How to join two images with "GD::Image"

am 25.06.2007 18:14:51 von Dean Arnold

Francesco Moi wrote:
>> Which efforts did you make to find out before asking here?
>
> I've been browsing
> http://search.cpan.org/dist/GD/GD.pm
>
> I didn't find out anything about "joining two images".
>
> I've been searching with Google:
> - "join two images" GD::Image perl
> - join images GD::Image perl
>

You have a nomenclature issue: "joining two images" isn't
a very precise description. Presumably you either want to
(a) composite two images, one on top of the other, or (b)
tile the images side by side. If you want (b), see
GD::Tiler. If you want (a), *and* you don't want any alpha
channel effect (ie, semitransparent overlays), then you can
just copy each image into a an output image object. If you
want alpha channels, you may need to consider Imager or
ImageMagick. GD purports to have alpha channel support, but
I've never had much luck getting it to work.

Dean Arnold
Presicient Corp.